qlocalsocket_unix.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/network/socket/qlocalsocket_unix.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtNetwork module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qlocalsocket.h"-
41#include "qlocalsocket_p.h"-
42#include "qnet_unix_p.h"-
43-
44#ifndef QT_NO_LOCALSOCKET-
45-
46#include <sys/types.h>-
47#include <sys/socket.h>-
48#include <sys/un.h>-
49#include <unistd.h>-
50#include <fcntl.h>-
51#include <errno.h>-
52-
53#include <qdir.h>-
54#include <qdebug.h>-
55#include <qelapsedtimer.h>-
56-
57#ifdef Q_OS_VXWORKS-
58# include <selectLib.h>-
59#endif-
60-
61#define QT_CONNECT_TIMEOUT 30000-
62-
63QT_BEGIN_NAMESPACE-
64-
65QLocalSocketPrivate::QLocalSocketPrivate() : QIODevicePrivate(),-
66 delayConnect(0),-
67 connectTimer(0),-
68 connectingSocket(-1),-
69 connectingOpenMode(0),-
70 state(QLocalSocket::UnconnectedState)-
71{-
72}
executed 165 times by 3 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_qlocalsocket - unknown status
165
73-
74void QLocalSocketPrivate::init()-
75{-
76 Q_Q(QLocalSocket);-
77 // QIODevice signals-
78 q->connect(&unixSocket, SIGNAL(aboutToClose()), q, SIGNAL(aboutToClose()));-
79 q->connect(&unixSocket, SIGNAL(bytesWritten(qint64)),-
80 q, SIGNAL(bytesWritten(qint64)));-
81 q->connect(&unixSocket, SIGNAL(readyRead()), q, SIGNAL(readyRead()));-
82 // QAbstractSocket signals-
83 q->connect(&unixSocket, SIGNAL(connected()), q, SIGNAL(connected()));-
84 q->connect(&unixSocket, SIGNAL(disconnected()), q, SIGNAL(disconnected()));-
85 q->connect(&unixSocket, SIGNAL(stateChanged(QAbstractSocket::SocketState)),-
86 q, SLOT(_q_stateChanged(QAbstractSocket::SocketState)));-
87 q->connect(&unixSocket, SIGNAL(error(QAbstractSocket::SocketError)),-
88 q, SLOT(_q_error(QAbstractSocket::SocketError)));-
89 q->connect(&unixSocket, SIGNAL(readChannelFinished()), q, SIGNAL(readChannelFinished()));-
90 unixSocket.setParent(q);-
91}
executed 165 times by 3 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_qlocalsocket - unknown status
165
92-
93void QLocalSocketPrivate::_q_error(QAbstractSocket::SocketError socketError)-
94{-
95 Q_Q(QLocalSocket);-
96 QString function = QLatin1String("QLocalSocket");-
97 QLocalSocket::LocalSocketError error = (QLocalSocket::LocalSocketError)socketError;-
98 QString errorString = generateErrorString(error, function);-
99 q->setErrorString(errorString);-
100 emit q->error(error);-
101}
executed 25 times by 3 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_qlocalsocket - unknown status
25
102-
103void QLocalSocketPrivate::_q_stateChanged(QAbstractSocket::SocketState newState)-
104{-
105 Q_Q(QLocalSocket);-
106 QLocalSocket::LocalSocketState currentState = state;-
107 switch(newState) {-
108 case QAbstractSocket::UnconnectedState:
executed 157 times by 3 tests: case QAbstractSocket::UnconnectedState:
Executed by:
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_qlocalsocket - unknown status
157
109 state = QLocalSocket::UnconnectedState;-
110 serverName.clear();-
111 fullServerName.clear();-
112 break;
executed 157 times by 3 tests: break;
Executed by:
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_qlocalsocket - unknown status
157
113 case QAbstractSocket::ConnectingState:
never executed: case QAbstractSocket::ConnectingState:
0
114 state = QLocalSocket::ConnectingState;-
115 break;
never executed: break;
0
116 case QAbstractSocket::ConnectedState:
executed 158 times by 3 tests: case QAbstractSocket::ConnectedState:
Executed by:
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_qlocalsocket - unknown status
158
117 state = QLocalSocket::ConnectedState;-
118 break;
executed 158 times by 3 tests: break;
Executed by:
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_qlocalsocket - unknown status
158
119 case QAbstractSocket::ClosingState:
executed 154 times by 3 tests: case QAbstractSocket::ClosingState:
Executed by:
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_qlocalsocket - unknown status
154
120 state = QLocalSocket::ClosingState;-
121 break;
executed 154 times by 3 tests: break;
Executed by:
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_qlocalsocket - unknown status
154
122 default:
never executed: default:
0
123#if defined QLOCALSOCKET_DEBUG-
124 qWarning() << "QLocalSocket::Unhandled socket state change:" << newState;-
125#endif-
126 return;
never executed: return;
0
127 }-
128 if (currentState != state)
currentState != stateDescription
TRUEevaluated 392 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_qlocalsocket - unknown status
FALSEevaluated 77 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_qlocalsocket - unknown status
77-392
129 emit q->stateChanged(state);
executed 392 times by 3 tests: q->stateChanged(state);
Executed by:
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_qlocalsocket - unknown status
392
130}
executed 469 times by 3 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_qlocalsocket - unknown status
469
131-
132QString QLocalSocketPrivate::generateErrorString(QLocalSocket::LocalSocketError error, const QString &function) const-
133{-
134 QString errorString;-
135 switch (error) {-
136 case QLocalSocket::ConnectionRefusedError:
never executed: case QLocalSocket::ConnectionRefusedError:
0
137 errorString = QLocalSocket::tr("%1: Connection refused").arg(function);-
138 break;
never executed: break;
0
139 case QLocalSocket::PeerClosedError:
executed 19 times by 3 tests: case QLocalSocket::PeerClosedError:
Executed by:
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_qlocalsocket - unknown status
19
140 errorString = QLocalSocket::tr("%1: Remote closed").arg(function);-
141 break;
executed 19 times by 3 tests: break;
Executed by:
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_qlocalsocket - unknown status
19
142 case QLocalSocket::ServerNotFoundError:
executed 8 times by 1 test: case QLocalSocket::ServerNotFoundError:
Executed by:
  • tst_qlocalsocket - unknown status
8
143 errorString = QLocalSocket::tr("%1: Invalid name").arg(function);-
144 break;
executed 8 times by 1 test: break;
Executed by:
  • tst_qlocalsocket - unknown status
8
145 case QLocalSocket::SocketAccessError:
never executed: case QLocalSocket::SocketAccessError:
0
146 errorString = QLocalSocket::tr("%1: Socket access error").arg(function);-
147 break;
never executed: break;
0
148 case QLocalSocket::SocketResourceError:
never executed: case QLocalSocket::SocketResourceError:
0
149 errorString = QLocalSocket::tr("%1: Socket resource error").arg(function);-
150 break;
never executed: break;
0
151 case QLocalSocket::SocketTimeoutError:
executed 6 times by 1 test: case QLocalSocket::SocketTimeoutError:
Executed by:
  • tst_qlocalsocket - unknown status
6
152 errorString = QLocalSocket::tr("%1: Socket operation timed out").arg(function);-
153 break;
executed 6 times by 1 test: break;
Executed by:
  • tst_qlocalsocket - unknown status
6
154 case QLocalSocket::DatagramTooLargeError:
never executed: case QLocalSocket::DatagramTooLargeError:
0
155 errorString = QLocalSocket::tr("%1: Datagram too large").arg(function);-
156 break;
never executed: break;
0
157 case QLocalSocket::ConnectionError:
never executed: case QLocalSocket::ConnectionError:
0
158 errorString = QLocalSocket::tr("%1: Connection error").arg(function);-
159 break;
never executed: break;
0
160 case QLocalSocket::UnsupportedSocketOperationError:
never executed: case QLocalSocket::UnsupportedSocketOperationError:
0
161 errorString = QLocalSocket::tr("%1: The socket operation is not supported").arg(function);-
162 break;
never executed: break;
0
163 case QLocalSocket::OperationError:
never executed: case QLocalSocket::OperationError:
0
164 errorString = QLocalSocket::tr("%1: Operation not permitted when socket is in this state").arg(function);-
165 break;
never executed: break;
0
166 case QLocalSocket::UnknownSocketError:
never executed: case QLocalSocket::UnknownSocketError:
0
167 default:
never executed: default:
0
168 errorString = QLocalSocket::tr("%1: Unknown error %2").arg(function).arg(errno);-
169 }
never executed: end of block
0
170 return errorString;
executed 33 times by 3 tests: return errorString;
Executed by:
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_qlocalsocket - unknown status
33
171}-
172-
173void QLocalSocketPrivate::errorOccurred(QLocalSocket::LocalSocketError error, const QString &function)-
174{-
175 Q_Q(QLocalSocket);-
176 switch (error) {-
177 case QLocalSocket::ConnectionRefusedError:
never executed: case QLocalSocket::ConnectionRefusedError:
0
178 unixSocket.setSocketError(QAbstractSocket::ConnectionRefusedError);-
179 break;
never executed: break;
0
180 case QLocalSocket::PeerClosedError:
never executed: case QLocalSocket::PeerClosedError:
0
181 unixSocket.setSocketError(QAbstractSocket::RemoteHostClosedError);-
182 break;
never executed: break;
0
183 case QLocalSocket::ServerNotFoundError:
executed 8 times by 1 test: case QLocalSocket::ServerNotFoundError:
Executed by:
  • tst_qlocalsocket - unknown status
8
184 unixSocket.setSocketError(QAbstractSocket::HostNotFoundError);-
185 break;
executed 8 times by 1 test: break;
Executed by:
  • tst_qlocalsocket - unknown status
8
186 case QLocalSocket::SocketAccessError:
never executed: case QLocalSocket::SocketAccessError:
0
187 unixSocket.setSocketError(QAbstractSocket::SocketAccessError);-
188 break;
never executed: break;
0
189 case QLocalSocket::SocketResourceError:
never executed: case QLocalSocket::SocketResourceError:
0
190 unixSocket.setSocketError(QAbstractSocket::SocketResourceError);-
191 break;
never executed: break;
0
192 case QLocalSocket::SocketTimeoutError:
never executed: case QLocalSocket::SocketTimeoutError:
0
193 unixSocket.setSocketError(QAbstractSocket::SocketTimeoutError);-
194 break;
never executed: break;
0
195 case QLocalSocket::DatagramTooLargeError:
never executed: case QLocalSocket::DatagramTooLargeError:
0
196 unixSocket.setSocketError(QAbstractSocket::DatagramTooLargeError);-
197 break;
never executed: break;
0
198 case QLocalSocket::ConnectionError:
never executed: case QLocalSocket::ConnectionError:
0
199 unixSocket.setSocketError(QAbstractSocket::NetworkError);-
200 break;
never executed: break;
0
201 case QLocalSocket::UnsupportedSocketOperationError:
never executed: case QLocalSocket::UnsupportedSocketOperationError:
0
202 unixSocket.setSocketError(QAbstractSocket::UnsupportedSocketOperationError);-
203 break;
never executed: break;
0
204 case QLocalSocket::UnknownSocketError:
never executed: case QLocalSocket::UnknownSocketError:
0
205 default:
never executed: default:
0
206 unixSocket.setSocketError(QAbstractSocket::UnknownSocketError);-
207 }
never executed: end of block
0
208-
209 QString errorString = generateErrorString(error, function);-
210 q->setErrorString(errorString);-
211 emit q->error(error);-
212-
213 // errors cause a disconnect-
214 unixSocket.setSocketState(QAbstractSocket::UnconnectedState);-
215 bool stateChanged = (state != QLocalSocket::UnconnectedState);-
216 state = QLocalSocket::UnconnectedState;-
217 q->close();-
218 if (stateChanged)
stateChangedDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qlocalsocket - unknown status
FALSEnever evaluated
0-8
219 q->emit stateChanged(state);
executed 8 times by 1 test: q-> stateChanged(state);
Executed by:
  • tst_qlocalsocket - unknown status
8
220}
executed 8 times by 1 test: end of block
Executed by:
  • tst_qlocalsocket - unknown status
8
221-
222void QLocalSocket::connectToServer(OpenMode openMode)-
223{-
224 Q_D(QLocalSocket);-
225 if (state() == ConnectedState || state() == ConnectingState) {
state() == ConnectedStateDescription
TRUEnever evaluated
FALSEevaluated 89 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qlocalsocket - unknown status
state() == ConnectingStateDescription
TRUEnever evaluated
FALSEevaluated 89 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qlocalsocket - unknown status
0-89
226 QString errorString = d->generateErrorString(QLocalSocket::OperationError, QLatin1String("QLocalSocket::connectToserver"));-
227 setErrorString(errorString);-
228 emit error(QLocalSocket::OperationError);-
229 return;
never executed: return;
0
230 }-
231-
232 d->errorString.clear();-
233 d->unixSocket.setSocketState(QAbstractSocket::ConnectingState);-
234 d->state = ConnectingState;-
235 emit stateChanged(d->state);-
236-
237 if (d->serverName.isEmpty()) {
d->serverName.isEmpty()Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • tst_qlocalsocket - unknown status
FALSEevaluated 82 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qlocalsocket - unknown status
7-82
238 d->errorOccurred(ServerNotFoundError,-
239 QLatin1String("QLocalSocket::connectToServer"));-
240 return;
executed 7 times by 1 test: return;
Executed by:
  • tst_qlocalsocket - unknown status
7
241 }-
242-
243 // create the socket-
244 if (-1 == (d->connectingSocket = qt_safe_socket(PF_UNIX, SOCK_STREAM, 0, O_NONBLOCK))) {
-1 == (d->conn...AM, 0, 04000))Description
TRUEnever evaluated
FALSEevaluated 82 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qlocalsocket - unknown status
0-82
245 d->errorOccurred(UnsupportedSocketOperationError,-
246 QLatin1String("QLocalSocket::connectToServer"));-
247 return;
never executed: return;
0
248 }-
249-
250 // _q_connectToSocket does the actual connecting-
251 d->connectingName = d->serverName;-
252 d->connectingOpenMode = openMode;-
253 d->_q_connectToSocket();-
254 return;
executed 82 times by 2 tests: return;
Executed by:
  • tst_QNetworkReply
  • tst_qlocalsocket - unknown status
82
255}-
256-
257/*!-
258 \internal-
259-
260 Tries to connect connectingName and connectingOpenMode-
261-
262 \sa connectToServer(), waitForConnected()-
263 */-
264void QLocalSocketPrivate::_q_connectToSocket()-
265{-
266 Q_Q(QLocalSocket);-
267 QString connectingPathName;-
268-
269 // determine the full server path-
270 if (connectingName.startsWith(QLatin1Char('/'))) {
connectingName...tin1Char('/'))Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qlocalsocket - unknown status
FALSEevaluated 81 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qlocalsocket - unknown status
1-81
271 connectingPathName = connectingName;-
272 } else {
executed 1 time by 1 test: end of block
Executed by:
  • tst_qlocalsocket - unknown status
1
273 connectingPathName = QDir::tempPath();-
274 connectingPathName += QLatin1Char('/') + connectingName;-
275 }
executed 81 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qlocalsocket - unknown status
81
276-
277 const QByteArray encodedConnectingPathName = QFile::encodeName(connectingPathName);-
278 struct sockaddr_un name;-
279 name.sun_family = PF_UNIX;-
280 if (sizeof(name.sun_path) < (uint)encodedConnectingPathName.size() + 1) {
sizeof(name.su...ame.size() + 1Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qlocalsocket - unknown status
FALSEevaluated 81 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qlocalsocket - unknown status
1-81
281 QString function = QLatin1String("QLocalSocket::connectToServer");-
282 errorOccurred(QLocalSocket::ServerNotFoundError, function);-
283 return;
executed 1 time by 1 test: return;
Executed by:
  • tst_qlocalsocket - unknown status
1
284 }-
285 ::memcpy(name.sun_path, encodedConnectingPathName.constData(),-
286 encodedConnectingPathName.size() + 1);-
287 if (-1 == qt_safe_connect(connectingSocket, (struct sockaddr *)&name, sizeof(name))) {
-1 == qt_safe_... sizeof(name))Description
TRUEnever evaluated
FALSEevaluated 81 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qlocalsocket - unknown status
0-81
288 QString function = QLatin1String("QLocalSocket::connectToServer");-
289 switch (errno)-
290 {-
291 case EINVAL:
never executed: case 22:
0
292 case ECONNREFUSED:
never executed: case 111:
0
293 errorOccurred(QLocalSocket::ConnectionRefusedError, function);-
294 break;
never executed: break;
0
295 case ENOENT:
never executed: case 2:
0
296 errorOccurred(QLocalSocket::ServerNotFoundError, function);-
297 break;
never executed: break;
0
298 case EACCES:
never executed: case 13:
0
299 case EPERM:
never executed: case 1:
0
300 errorOccurred(QLocalSocket::SocketAccessError, function);-
301 break;
never executed: break;
0
302 case ETIMEDOUT:
never executed: case 110:
0
303 errorOccurred(QLocalSocket::SocketTimeoutError, function);-
304 break;
never executed: break;
0
305 case EAGAIN:
never executed: case 11:
0
306 // Try again later, all of the sockets listening are full-
307 if (!delayConnect) {
!delayConnectDescription
TRUEnever evaluated
FALSEnever evaluated
0
308 delayConnect = new QSocketNotifier(connectingSocket, QSocketNotifier::Write, q);-
309 q->connect(delayConnect, SIGNAL(activated(int)), q, SLOT(_q_connectToSocket()));-
310 }
never executed: end of block
0
311 if (!connectTimer) {
!connectTimerDescription
TRUEnever evaluated
FALSEnever evaluated
0
312 connectTimer = new QTimer(q);-
313 q->connect(connectTimer, SIGNAL(timeout()),-
314 q, SLOT(_q_abortConnectionAttempt()),-
315 Qt::DirectConnection);-
316 connectTimer->start(QT_CONNECT_TIMEOUT);-
317 }
never executed: end of block
0
318 delayConnect->setEnabled(true);-
319 break;
never executed: break;
0
320 default:
never executed: default:
0
321 errorOccurred(QLocalSocket::UnknownSocketError, function);-
322 }
never executed: end of block
0
323 return;
never executed: return;
0
324 }-
325-
326 // connected!-
327 cancelDelayedConnect();-
328-
329 serverName = connectingName;-
330 fullServerName = connectingPathName;-
331 if (unixSocket.setSocketDescriptor(connectingSocket,
unixSocket.set...ctingOpenMode)Description
TRUEevaluated 81 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qlocalsocket - unknown status
FALSEnever evaluated
0-81
332 QAbstractSocket::ConnectedState, connectingOpenMode)) {
unixSocket.set...ctingOpenMode)Description
TRUEevaluated 81 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qlocalsocket - unknown status
FALSEnever evaluated
0-81
333 q->QIODevice::open(connectingOpenMode | QIODevice::Unbuffered);-
334 q->emit connected();-
335 } else {
executed 81 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qlocalsocket - unknown status
81
336 QString function = QLatin1String("QLocalSocket::connectToServer");-
337 errorOccurred(QLocalSocket::UnknownSocketError, function);-
338 }
never executed: end of block
0
339 connectingSocket = -1;-
340 connectingName.clear();-
341 connectingOpenMode = 0;-
342}
executed 81 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qlocalsocket - unknown status
81
343-
344bool QLocalSocket::setSocketDescriptor(qintptr socketDescriptor,-
345 LocalSocketState socketState, OpenMode openMode)-
346{-
347 Q_D(QLocalSocket);-
348 QAbstractSocket::SocketState newSocketState = QAbstractSocket::UnconnectedState;-
349 switch (socketState) {-
350 case ConnectingState:
executed 1 time by 1 test: case ConnectingState:
Executed by:
  • tst_qlocalsocket - unknown status
1
351 newSocketState = QAbstractSocket::ConnectingState;-
352 break;
executed 1 time by 1 test: break;
Executed by:
  • tst_qlocalsocket - unknown status
1
353 case ConnectedState:
executed 77 times by 3 tests: case ConnectedState:
Executed by:
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_qlocalsocket - unknown status
77
354 newSocketState = QAbstractSocket::ConnectedState;-
355 break;
executed 77 times by 3 tests: break;
Executed by:
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_qlocalsocket - unknown status
77
356 case ClosingState:
never executed: case ClosingState:
0
357 newSocketState = QAbstractSocket::ClosingState;-
358 break;
never executed: break;
0
359 case UnconnectedState:
never executed: case UnconnectedState:
0
360 newSocketState = QAbstractSocket::UnconnectedState;-
361 break;
never executed: break;
0
362 }-
363 QIODevice::open(openMode);-
364 d->state = socketState;-
365 return d->unixSocket.setSocketDescriptor(socketDescriptor,
executed 78 times by 3 tests: return d->unixSocket.setSocketDescriptor(socketDescriptor, newSocketState, openMode);
Executed by:
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_qlocalsocket - unknown status
78
366 newSocketState, openMode);
executed 78 times by 3 tests: return d->unixSocket.setSocketDescriptor(socketDescriptor, newSocketState, openMode);
Executed by:
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_qlocalsocket - unknown status
78
367}-
368-
369void QLocalSocketPrivate::_q_abortConnectionAttempt()-
370{-
371 Q_Q(QLocalSocket);-
372 q->close();-
373}
never executed: end of block
0
374-
375void QLocalSocketPrivate::cancelDelayedConnect()-
376{-
377 if (delayConnect) {
delayConnectDescription
TRUEnever evaluated
FALSEevaluated 305 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_qlocalsocket - unknown status
0-305
378 delayConnect->setEnabled(false);-
379 delete delayConnect;-
380 delayConnect = 0;-
381 connectTimer->stop();-
382 delete connectTimer;-
383 connectTimer = 0;-
384 }
never executed: end of block
0
385}
executed 305 times by 3 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_qlocalsocket - unknown status
305
386-
387qintptr QLocalSocket::socketDescriptor() const-
388{-
389 Q_D(const QLocalSocket);-
390 return d->unixSocket.socketDescriptor();
executed 1 time by 1 test: return d->unixSocket.socketDescriptor();
Executed by:
  • tst_qlocalsocket - unknown status
1
391}-
392-
393qint64 QLocalSocket::readData(char *data, qint64 c)-
394{-
395 Q_D(QLocalSocket);-
396 return d->unixSocket.read(data, c);
executed 4330 times by 2 tests: return d->unixSocket.read(data, c);
Executed by:
  • tst_QNetworkReply
  • tst_qlocalsocket - unknown status
4330
397}-
398-
399qint64 QLocalSocket::writeData(const char *data, qint64 c)-
400{-
401 Q_D(QLocalSocket);-
402 return d->unixSocket.writeData(data, c);
executed 2573 times by 2 tests: return d->unixSocket.writeData(data, c);
Executed by:
  • tst_QNetworkReply
  • tst_qlocalsocket - unknown status
2573
403}-
404-
405void QLocalSocket::abort()-
406{-
407 Q_D(QLocalSocket);-
408 d->unixSocket.abort();-
409}
executed 5 times by 1 test: end of block
Executed by:
  • tst_qlocalsocket - unknown status
5
410-
411qint64 QLocalSocket::bytesAvailable() const-
412{-
413 Q_D(const QLocalSocket);-
414 return QIODevice::bytesAvailable() + d->unixSocket.bytesAvailable();
executed 5112 times by 2 tests: return QIODevice::bytesAvailable() + d->unixSocket.bytesAvailable();
Executed by:
  • tst_QNetworkReply
  • tst_qlocalsocket - unknown status
5112
415}-
416-
417qint64 QLocalSocket::bytesToWrite() const-
418{-
419 Q_D(const QLocalSocket);-
420 return d->unixSocket.bytesToWrite();
executed 4018 times by 1 test: return d->unixSocket.bytesToWrite();
Executed by:
  • tst_qlocalsocket - unknown status
4018
421}-
422-
423bool QLocalSocket::canReadLine() const-
424{-
425 Q_D(const QLocalSocket);-
426 return QIODevice::canReadLine() || d->unixSocket.canReadLine();
executed 14 times by 1 test: return QIODevice::canReadLine() || d->unixSocket.canReadLine();
Executed by:
  • tst_qlocalsocket - unknown status
14
427}-
428-
429void QLocalSocket::close()-
430{-
431 Q_D(QLocalSocket);-
432 d->unixSocket.close();-
433 d->cancelDelayedConnect();-
434 if (d->connectingSocket != -1)
d->connectingSocket != -1Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qlocalsocket - unknown status
FALSEevaluated 223 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_qlocalsocket - unknown status
1-223
435 ::close(d->connectingSocket);
executed 1 time by 1 test: ::close(d->connectingSocket);
Executed by:
  • tst_qlocalsocket - unknown status
1
436 d->connectingSocket = -1;-
437 d->connectingName.clear();-
438 d->connectingOpenMode = 0;-
439 d->serverName.clear();-
440 d->fullServerName.clear();-
441 QIODevice::close();-
442}
executed 224 times by 3 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_qlocalsocket - unknown status
224
443-
444bool QLocalSocket::waitForBytesWritten(int msecs)-
445{-
446 Q_D(QLocalSocket);-
447 return d->unixSocket.waitForBytesWritten(msecs);
executed 2042 times by 1 test: return d->unixSocket.waitForBytesWritten(msecs);
Executed by:
  • tst_qlocalsocket - unknown status
2042
448}-
449-
450bool QLocalSocket::flush()-
451{-
452 Q_D(QLocalSocket);-
453 return d->unixSocket.flush();
executed 17 times by 1 test: return d->unixSocket.flush();
Executed by:
  • tst_qlocalsocket - unknown status
17
454}-
455-
456void QLocalSocket::disconnectFromServer()-
457{-
458 Q_D(QLocalSocket);-
459 d->unixSocket.disconnectFromHost();-
460}
executed 6 times by 1 test: end of block
Executed by:
  • tst_qlocalsocket - unknown status
6
461-
462QLocalSocket::LocalSocketError QLocalSocket::error() const-
463{-
464 Q_D(const QLocalSocket);-
465 switch (d->unixSocket.error()) {-
466 case QAbstractSocket::ConnectionRefusedError:
never executed: case QAbstractSocket::ConnectionRefusedError:
0
467 return QLocalSocket::ConnectionRefusedError;
never executed: return QLocalSocket::ConnectionRefusedError;
0
468 case QAbstractSocket::RemoteHostClosedError:
executed 1 time by 1 test: case QAbstractSocket::RemoteHostClosedError:
Executed by:
  • tst_qlocalsocket - unknown status
1
469 return QLocalSocket::PeerClosedError;
executed 1 time by 1 test: return QLocalSocket::PeerClosedError;
Executed by:
  • tst_qlocalsocket - unknown status
1
470 case QAbstractSocket::HostNotFoundError:
executed 14 times by 1 test: case QAbstractSocket::HostNotFoundError:
Executed by:
  • tst_qlocalsocket - unknown status
14
471 return QLocalSocket::ServerNotFoundError;
executed 14 times by 1 test: return QLocalSocket::ServerNotFoundError;
Executed by:
  • tst_qlocalsocket - unknown status
14
472 case QAbstractSocket::SocketAccessError:
never executed: case QAbstractSocket::SocketAccessError:
0
473 return QLocalSocket::SocketAccessError;
never executed: return QLocalSocket::SocketAccessError;
0
474 case QAbstractSocket::SocketResourceError:
never executed: case QAbstractSocket::SocketResourceError:
0
475 return QLocalSocket::SocketResourceError;
never executed: return QLocalSocket::SocketResourceError;
0
476 case QAbstractSocket::SocketTimeoutError:
executed 6 times by 1 test: case QAbstractSocket::SocketTimeoutError:
Executed by:
  • tst_qlocalsocket - unknown status
6
477 return QLocalSocket::SocketTimeoutError;
executed 6 times by 1 test: return QLocalSocket::SocketTimeoutError;
Executed by:
  • tst_qlocalsocket - unknown status
6
478 case QAbstractSocket::DatagramTooLargeError:
never executed: case QAbstractSocket::DatagramTooLargeError:
0
479 return QLocalSocket::DatagramTooLargeError;
never executed: return QLocalSocket::DatagramTooLargeError;
0
480 case QAbstractSocket::NetworkError:
never executed: case QAbstractSocket::NetworkError:
0
481 return QLocalSocket::ConnectionError;
never executed: return QLocalSocket::ConnectionError;
0
482 case QAbstractSocket::UnsupportedSocketOperationError:
never executed: case QAbstractSocket::UnsupportedSocketOperationError:
0
483 return QLocalSocket::UnsupportedSocketOperationError;
never executed: return QLocalSocket::UnsupportedSocketOperationError;
0
484 case QAbstractSocket::UnknownSocketError:
executed 7 times by 1 test: case QAbstractSocket::UnknownSocketError:
Executed by:
  • tst_qlocalsocket - unknown status
7
485 return QLocalSocket::UnknownSocketError;
executed 7 times by 1 test: return QLocalSocket::UnknownSocketError;
Executed by:
  • tst_qlocalsocket - unknown status
7
486 default:
never executed: default:
0
487#if defined QLOCALSOCKET_DEBUG-
488 qWarning() << "QLocalSocket error not handled:" << d->unixSocket.error();-
489#endif-
490 break;
never executed: break;
0
491 }-
492 return UnknownSocketError;
never executed: return UnknownSocketError;
0
493}-
494-
495bool QLocalSocket::isValid() const-
496{-
497 Q_D(const QLocalSocket);-
498 return d->unixSocket.isValid();
executed 20 times by 1 test: return d->unixSocket.isValid();
Executed by:
  • tst_qlocalsocket - unknown status
20
499}-
500-
501qint64 QLocalSocket::readBufferSize() const-
502{-
503 Q_D(const QLocalSocket);-
504 return d->unixSocket.readBufferSize();
executed 14 times by 1 test: return d->unixSocket.readBufferSize();
Executed by:
  • tst_qlocalsocket - unknown status
14
505}-
506-
507void QLocalSocket::setReadBufferSize(qint64 size)-
508{-
509 Q_D(QLocalSocket);-
510 d->unixSocket.setReadBufferSize(size);-
511}
executed 2 times by 1 test: end of block
Executed by:
  • tst_qlocalsocket - unknown status
2
512-
513bool QLocalSocket::waitForConnected(int msec)-
514{-
515 Q_D(QLocalSocket);-
516-
517 if (state() != ConnectingState)
state() != ConnectingStateDescription
TRUEevaluated 78 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qlocalsocket - unknown status
FALSEnever evaluated
0-78
518 return (state() == ConnectedState);
executed 78 times by 2 tests: return (state() == ConnectedState);
Executed by:
  • tst_QNetworkReply
  • tst_qlocalsocket - unknown status
78
519-
520 QElapsedTimer timer;-
521 timer.start();-
522-
523 pollfd pfd = qt_make_pollfd(d->connectingSocket, POLLIN);-
524-
525 do {-
526 const int timeout = (msec > 0) ? qMax(msec - timer.elapsed(), Q_INT64_C(0)) : msec;
(msec > 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
527 const int result = qt_poll_msecs(&pfd, 1, timeout);-
528-
529 if (result == -1)
result == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
530 d->errorOccurred(QLocalSocket::UnknownSocketError,
never executed: d->errorOccurred(QLocalSocket::UnknownSocketError, QLatin1String("QLocalSocket::waitForConnected"));
0
531 QLatin1String("QLocalSocket::waitForConnected"));
never executed: d->errorOccurred(QLocalSocket::UnknownSocketError, QLatin1String("QLocalSocket::waitForConnected"));
0
532 else if (result > 0)
result > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
533 d->_q_connectToSocket();
never executed: d->_q_connectToSocket();
0
534 } while (state() == ConnectingState && !timer.hasExpired(msec));
never executed: end of block
state() == ConnectingStateDescription
TRUEnever evaluated
FALSEnever evaluated
!timer.hasExpired(msec)Description
TRUEnever evaluated
FALSEnever evaluated
0
535-
536 return (state() == ConnectedState);
never executed: return (state() == ConnectedState);
0
537}-
538-
539bool QLocalSocket::waitForDisconnected(int msecs)-
540{-
541 Q_D(QLocalSocket);-
542 if (state() == UnconnectedState) {
state() == UnconnectedStateDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qlocalsocket - unknown status
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_qlocalsocket - unknown status
1-5
543 qWarning("QLocalSocket::waitForDisconnected() is not allowed in UnconnectedState");-
544 return false;
executed 1 time by 1 test: return false;
Executed by:
  • tst_qlocalsocket - unknown status
1
545 }-
546 return (d->unixSocket.waitForDisconnected(msecs));
executed 5 times by 1 test: return (d->unixSocket.waitForDisconnected(msecs));
Executed by:
  • tst_qlocalsocket - unknown status
5
547}-
548-
549bool QLocalSocket::waitForReadyRead(int msecs)-
550{-
551 Q_D(QLocalSocket);-
552 if (state() == QLocalSocket::UnconnectedState)
state() == QLo...connectedStateDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • tst_qlocalsocket - unknown status
FALSEevaluated 2049 times by 2 tests
Evaluated by:
  • tst_QNetworkSession
  • tst_qlocalsocket - unknown status
7-2049
553 return false;
executed 7 times by 1 test: return false;
Executed by:
  • tst_qlocalsocket - unknown status
7
554 return (d->unixSocket.waitForReadyRead(msecs));
executed 2049 times by 2 tests: return (d->unixSocket.waitForReadyRead(msecs));
Executed by:
  • tst_QNetworkSession
  • tst_qlocalsocket - unknown status
2049
555}-
556-
557QT_END_NAMESPACE-
558-
559#endif-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9