Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | | - |
10 | | - |
11 | | - |
12 | | - |
13 | | - |
14 | | - |
15 | | - |
16 | | - |
17 | | - |
18 | QLocalSocketPrivate::QLocalSocketPrivate() : QIODevicePrivate(), | - |
19 | delayConnect(0), | - |
20 | connectTimer(0), | - |
21 | connectingSocket(-1), | - |
22 | connectingOpenMode(0), | - |
23 | state(QLocalSocket::UnconnectedState) | - |
24 | { | - |
25 | } executed: } Execution Count:156 | 156 |
26 | | - |
27 | void QLocalSocketPrivate::init() | - |
28 | { | - |
29 | QLocalSocket * const q = q_func(); | - |
30 | | - |
31 | q->connect(&unixSocket, "2""aboutToClose()", q, "2""aboutToClose()"); | - |
32 | q->connect(&unixSocket, "2""bytesWritten(qint64)", | - |
33 | q, "2""bytesWritten(qint64)"); | - |
34 | q->connect(&unixSocket, "2""readyRead()", q, "2""readyRead()"); | - |
35 | | - |
36 | q->connect(&unixSocket, "2""connected()", q, "2""connected()"); | - |
37 | q->connect(&unixSocket, "2""disconnected()", q, "2""disconnected()"); | - |
38 | q->connect(&unixSocket, "2""stateChanged(QAbstractSocket::SocketState)", | - |
39 | q, "1""_q_stateChanged(QAbstractSocket::SocketState)"); | - |
40 | q->connect(&unixSocket, "2""error(QAbstractSocket::SocketError)", | - |
41 | q, "1""_q_error(QAbstractSocket::SocketError)"); | - |
42 | q->connect(&unixSocket, "2""readChannelFinished()", q, "2""readChannelFinished()"); | - |
43 | unixSocket.setParent(q); | - |
44 | } executed: } Execution Count:157 | 157 |
45 | | - |
46 | void QLocalSocketPrivate::_q_error(QAbstractSocket::SocketError socketError) | - |
47 | { | - |
48 | QLocalSocket * const q = q_func(); | - |
49 | QString function = QLatin1String("QLocalSocket"); | - |
50 | QLocalSocket::LocalSocketError error = (QLocalSocket::LocalSocketError)socketError; | - |
51 | QString errorString = generateErrorString(error, function); | - |
52 | q->setErrorString(errorString); | - |
53 | q->error(error); | - |
54 | } executed: } Execution Count:21 | 21 |
55 | | - |
56 | void QLocalSocketPrivate::_q_stateChanged(QAbstractSocket::SocketState newState) | - |
57 | { | - |
58 | QLocalSocket * const q = q_func(); | - |
59 | QLocalSocket::LocalSocketState currentState = state; | - |
60 | switch(newState) { | - |
61 | case QAbstractSocket::UnconnectedState: | - |
62 | state = QLocalSocket::UnconnectedState; | - |
63 | serverName.clear(); | - |
64 | fullServerName.clear(); | - |
65 | break; executed: break; Execution Count:143 | 143 |
66 | case QAbstractSocket::ConnectingState: | - |
67 | state = QLocalSocket::ConnectingState; | - |
68 | break; | 0 |
69 | case QAbstractSocket::ConnectedState: | - |
70 | state = QLocalSocket::ConnectedState; | - |
71 | break; executed: break; Execution Count:146 | 146 |
72 | case QAbstractSocket::ClosingState: | - |
73 | state = QLocalSocket::ClosingState; | - |
74 | break; executed: break; Execution Count:146 | 146 |
75 | default: | - |
76 | | - |
77 | | - |
78 | | - |
79 | return; | 0 |
80 | } | - |
81 | if (currentState != state) evaluated: currentState != state yes Evaluation Count:364 | yes Evaluation Count:71 |
| 71-364 |
82 | q->stateChanged(state); executed: q->stateChanged(state); Execution Count:364 | 364 |
83 | } executed: } Execution Count:435 | 435 |
84 | | - |
85 | QString QLocalSocketPrivate::generateErrorString(QLocalSocket::LocalSocketError error, const QString &function) const | - |
86 | { | - |
87 | QString errorString; | - |
88 | switch (error) { | - |
89 | case QLocalSocket::ConnectionRefusedError: | - |
90 | errorString = QLocalSocket::tr("%1: Connection refused").arg(function); | - |
91 | break; | 0 |
92 | case QLocalSocket::PeerClosedError: | - |
93 | errorString = QLocalSocket::tr("%1: Remote closed").arg(function); | - |
94 | break; executed: break; Execution Count:15 | 15 |
95 | case QLocalSocket::ServerNotFoundError: | - |
96 | errorString = QLocalSocket::tr("%1: Invalid name").arg(function); | - |
97 | break; executed: break; Execution Count:10 | 10 |
98 | case QLocalSocket::SocketAccessError: | - |
99 | errorString = QLocalSocket::tr("%1: Socket access error").arg(function); | - |
100 | break; | 0 |
101 | case QLocalSocket::SocketResourceError: | - |
102 | errorString = QLocalSocket::tr("%1: Socket resource error").arg(function); | - |
103 | break; | 0 |
104 | case QLocalSocket::SocketTimeoutError: | - |
105 | errorString = QLocalSocket::tr("%1: Socket operation timed out").arg(function); | - |
106 | break; executed: break; Execution Count:6 | 6 |
107 | case QLocalSocket::DatagramTooLargeError: | - |
108 | errorString = QLocalSocket::tr("%1: Datagram too large").arg(function); | - |
109 | break; | 0 |
110 | case QLocalSocket::ConnectionError: | - |
111 | errorString = QLocalSocket::tr("%1: Connection error").arg(function); | - |
112 | break; | 0 |
113 | case QLocalSocket::UnsupportedSocketOperationError: | - |
114 | errorString = QLocalSocket::tr("%1: The socket operation is not supported").arg(function); | - |
115 | break; | 0 |
116 | case QLocalSocket::OperationError: | - |
117 | errorString = QLocalSocket::tr("%1: Operation not permitted when socket is in this state").arg(function); | - |
118 | break; | 0 |
119 | case QLocalSocket::UnknownSocketError: | - |
120 | default: | - |
121 | errorString = QLocalSocket::tr("%1: Unknown error %2").arg(function).arg((*__errno_location ())); | - |
122 | } | 0 |
123 | return errorString; executed: return errorString; Execution Count:31 | 31 |
124 | } | - |
125 | | - |
126 | void QLocalSocketPrivate::errorOccurred(QLocalSocket::LocalSocketError error, const QString &function) | - |
127 | { | - |
128 | QLocalSocket * const q = q_func(); | - |
129 | switch (error) { | - |
130 | case QLocalSocket::ConnectionRefusedError: | - |
131 | unixSocket.setSocketError(QAbstractSocket::ConnectionRefusedError); | - |
132 | break; | 0 |
133 | case QLocalSocket::PeerClosedError: | - |
134 | unixSocket.setSocketError(QAbstractSocket::RemoteHostClosedError); | - |
135 | break; | 0 |
136 | case QLocalSocket::ServerNotFoundError: | - |
137 | unixSocket.setSocketError(QAbstractSocket::HostNotFoundError); | - |
138 | break; executed: break; Execution Count:10 | 10 |
139 | case QLocalSocket::SocketAccessError: | - |
140 | unixSocket.setSocketError(QAbstractSocket::SocketAccessError); | - |
141 | break; | 0 |
142 | case QLocalSocket::SocketResourceError: | - |
143 | unixSocket.setSocketError(QAbstractSocket::SocketResourceError); | - |
144 | break; | 0 |
145 | case QLocalSocket::SocketTimeoutError: | - |
146 | unixSocket.setSocketError(QAbstractSocket::SocketTimeoutError); | - |
147 | break; | 0 |
148 | case QLocalSocket::DatagramTooLargeError: | - |
149 | unixSocket.setSocketError(QAbstractSocket::DatagramTooLargeError); | - |
150 | break; | 0 |
151 | case QLocalSocket::ConnectionError: | - |
152 | unixSocket.setSocketError(QAbstractSocket::NetworkError); | - |
153 | break; | 0 |
154 | case QLocalSocket::UnsupportedSocketOperationError: | - |
155 | unixSocket.setSocketError(QAbstractSocket::UnsupportedSocketOperationError); | - |
156 | break; | 0 |
157 | case QLocalSocket::UnknownSocketError: | - |
158 | default: | - |
159 | unixSocket.setSocketError(QAbstractSocket::UnknownSocketError); | - |
160 | } | 0 |
161 | | - |
162 | QString errorString = generateErrorString(error, function); | - |
163 | q->setErrorString(errorString); | - |
164 | q->error(error); | - |
165 | | - |
166 | | - |
167 | unixSocket.setSocketState(QAbstractSocket::UnconnectedState); | - |
168 | bool stateChanged = (state != QLocalSocket::UnconnectedState); | - |
169 | state = QLocalSocket::UnconnectedState; | - |
170 | q->close(); | - |
171 | if (stateChanged) partially evaluated: stateChanged yes Evaluation Count:10 | no Evaluation Count:0 |
| 0-10 |
172 | q-> stateChanged(state); executed: q-> stateChanged(state); Execution Count:10 | 10 |
173 | } executed: } Execution Count:10 | 10 |
174 | | - |
175 | void QLocalSocket::connectToServer(const QString &name, OpenMode openMode) | - |
176 | { | - |
177 | QLocalSocketPrivate * const d = d_func(); | - |
178 | if (state() == ConnectedState || state() == ConnectingState) { partially evaluated: state() == ConnectedState no Evaluation Count:0 | yes Evaluation Count:85 |
partially evaluated: state() == ConnectingState no Evaluation Count:0 | yes Evaluation Count:85 |
| 0-85 |
179 | QString errorString = d->generateErrorString(QLocalSocket::OperationError, QLatin1String("QLocalSocket::connectToserver")); | - |
180 | setErrorString(errorString); | - |
181 | error(QLocalSocket::OperationError); | - |
182 | return; | 0 |
183 | } | - |
184 | | - |
185 | d->errorString.clear(); | - |
186 | d->unixSocket.setSocketState(QAbstractSocket::ConnectingState); | - |
187 | d->state = ConnectingState; | - |
188 | stateChanged(d->state); | - |
189 | | - |
190 | if (name.isEmpty()) { evaluated: name.isEmpty() yes Evaluation Count:9 | yes Evaluation Count:76 |
| 9-76 |
191 | d->errorOccurred(ServerNotFoundError, | - |
192 | QLatin1String("QLocalSocket::connectToServer")); | - |
193 | return; executed: return; Execution Count:9 | 9 |
194 | } | - |
195 | | - |
196 | | - |
197 | if (-1 == (d->connectingSocket = qt_safe_socket(1, SOCK_STREAM, 0))) { partially evaluated: -1 == (d->connectingSocket = qt_safe_socket(1, SOCK_STREAM, 0)) no Evaluation Count:0 | yes Evaluation Count:76 |
| 0-76 |
198 | d->errorOccurred(UnsupportedSocketOperationError, | - |
199 | QLatin1String("QLocalSocket::connectToServer")); | - |
200 | return; | 0 |
201 | } | - |
202 | | - |
203 | int flags = fcntl(d->connectingSocket, 3, 0); | - |
204 | if (-1 == flags partially evaluated: -1 == flags no Evaluation Count:0 | yes Evaluation Count:76 |
| 0-76 |
205 | || -1 == (fcntl(d->connectingSocket, 4, flags | 04000))) { partially evaluated: -1 == (fcntl(d->connectingSocket, 4, flags | 04000)) no Evaluation Count:0 | yes Evaluation Count:76 |
| 0-76 |
206 | d->errorOccurred(UnknownSocketError, | - |
207 | QLatin1String("QLocalSocket::connectToServer")); | - |
208 | return; | 0 |
209 | } | - |
210 | | - |
211 | | - |
212 | d->connectingName = name; | - |
213 | d->connectingOpenMode = openMode; | - |
214 | d->_q_connectToSocket(); | - |
215 | } executed: } Execution Count:76 | 76 |
216 | void QLocalSocketPrivate::_q_connectToSocket() | - |
217 | { | - |
218 | QLocalSocket * const q = q_func(); | - |
219 | QString connectingPathName; | - |
220 | | - |
221 | | - |
222 | if (connectingName.startsWith(QLatin1Char('/'))) { evaluated: connectingName.startsWith(QLatin1Char('/')) yes Evaluation Count:1 | yes Evaluation Count:75 |
| 1-75 |
223 | connectingPathName = connectingName; | - |
224 | } else { executed: } Execution Count:1 | 1 |
225 | connectingPathName = QDir::tempPath(); | - |
226 | connectingPathName += QLatin1Char('/') + connectingName; | - |
227 | } executed: } Execution Count:75 | 75 |
228 | | - |
229 | struct sockaddr_un name; | - |
230 | name.sun_family = 1; | - |
231 | if (sizeof(name.sun_path) < (uint)connectingPathName.toLatin1().size() + 1) { evaluated: sizeof(name.sun_path) < (uint)connectingPathName.toLatin1().size() + 1 yes Evaluation Count:1 | yes Evaluation Count:75 |
| 1-75 |
232 | QString function = QLatin1String("QLocalSocket::connectToServer"); | - |
233 | errorOccurred(QLocalSocket::ServerNotFoundError, function); | - |
234 | return; executed: return; Execution Count:1 | 1 |
235 | } | - |
236 | ::memcpy(name.sun_path, connectingPathName.toLatin1().data(), | - |
237 | connectingPathName.toLatin1().size() + 1); | - |
238 | if (-1 == qt_safe_connect(connectingSocket, (struct sockaddr *)&name, sizeof(name))) { partially evaluated: -1 == qt_safe_connect(connectingSocket, (struct sockaddr *)&name, sizeof(name)) no Evaluation Count:0 | yes Evaluation Count:75 |
| 0-75 |
239 | QString function = QLatin1String("QLocalSocket::connectToServer"); | - |
240 | switch ((*__errno_location ())) | - |
241 | { | - |
242 | case 22: | - |
243 | case 111: | - |
244 | errorOccurred(QLocalSocket::ConnectionRefusedError, function); | - |
245 | break; | 0 |
246 | case 2: | - |
247 | errorOccurred(QLocalSocket::ServerNotFoundError, function); | - |
248 | break; | 0 |
249 | case 13: | - |
250 | case 1: | - |
251 | errorOccurred(QLocalSocket::SocketAccessError, function); | - |
252 | break; | 0 |
253 | case 110: | - |
254 | errorOccurred(QLocalSocket::SocketTimeoutError, function); | - |
255 | break; | 0 |
256 | case 11: | - |
257 | | - |
258 | if (!delayConnect) { never evaluated: !delayConnect | 0 |
259 | delayConnect = new QSocketNotifier(connectingSocket, QSocketNotifier::Write, q); | - |
260 | q->connect(delayConnect, "2""activated(int)", q, "1""_q_connectToSocket()"); | - |
261 | } | 0 |
262 | if (!connectTimer) { never evaluated: !connectTimer | 0 |
263 | connectTimer = new QTimer(q); | - |
264 | q->connect(connectTimer, "2""timeout()", | - |
265 | q, "1""_q_abortConnectionAttempt()", | - |
266 | Qt::DirectConnection); | - |
267 | connectTimer->start(30000); | - |
268 | } | 0 |
269 | delayConnect->setEnabled(true); | - |
270 | break; | 0 |
271 | default: | - |
272 | errorOccurred(QLocalSocket::UnknownSocketError, function); | - |
273 | } | 0 |
274 | return; | 0 |
275 | } | - |
276 | | - |
277 | | - |
278 | cancelDelayedConnect(); | - |
279 | | - |
280 | serverName = connectingName; | - |
281 | fullServerName = connectingPathName; | - |
282 | if (unixSocket.setSocketDescriptor(connectingSocket, | 0-75 |
283 | QAbstractSocket::ConnectedState, connectingOpenMode)) { partially evaluated: unixSocket.setSocketDescriptor(connectingSocket, QAbstractSocket::ConnectedState, connectingOpenMode) yes Evaluation Count:75 | no Evaluation Count:0 |
| 0-75 |
284 | q->QIODevice::open(connectingOpenMode | QIODevice::Unbuffered); | - |
285 | q-> connected(); | - |
286 | } else { executed: } Execution Count:75 | 75 |
287 | QString function = QLatin1String("QLocalSocket::connectToServer"); | - |
288 | errorOccurred(QLocalSocket::UnknownSocketError, function); | - |
289 | } | 0 |
290 | connectingSocket = -1; | - |
291 | connectingName.clear(); | - |
292 | connectingOpenMode = 0; | - |
293 | } executed: } Execution Count:75 | 75 |
294 | | - |
295 | bool QLocalSocket::setSocketDescriptor(qintptr socketDescriptor, | - |
296 | LocalSocketState socketState, OpenMode openMode) | - |
297 | { | - |
298 | QLocalSocketPrivate * const d = d_func(); | - |
299 | QAbstractSocket::SocketState newSocketState = QAbstractSocket::UnconnectedState; | - |
300 | switch (socketState) { | - |
301 | case ConnectingState: | - |
302 | newSocketState = QAbstractSocket::ConnectingState; | - |
303 | break; executed: break; Execution Count:1 | 1 |
304 | case ConnectedState: | - |
305 | newSocketState = QAbstractSocket::ConnectedState; | - |
306 | break; executed: break; Execution Count:71 | 71 |
307 | case ClosingState: | - |
308 | newSocketState = QAbstractSocket::ClosingState; | - |
309 | break; | 0 |
310 | case UnconnectedState: | - |
311 | newSocketState = QAbstractSocket::UnconnectedState; | - |
312 | break; | 0 |
313 | } | - |
314 | QIODevice::open(openMode); | - |
315 | d->state = socketState; | - |
316 | return d->unixSocket.setSocketDescriptor(socketDescriptor, | 72 |
317 | newSocketState, openMode); executed: return d->unixSocket.setSocketDescriptor(socketDescriptor, newSocketState, openMode); Execution Count:72 | 72 |
318 | } | - |
319 | | - |
320 | void QLocalSocketPrivate::_q_abortConnectionAttempt() | - |
321 | { | - |
322 | QLocalSocket * const q = q_func(); | - |
323 | q->close(); | - |
324 | } | 0 |
325 | | - |
326 | void QLocalSocketPrivate::cancelDelayedConnect() | - |
327 | { | - |
328 | if (delayConnect) { partially evaluated: delayConnect no Evaluation Count:0 | yes Evaluation Count:290 |
| 0-290 |
329 | delayConnect->setEnabled(false); | - |
330 | delete delayConnect; | - |
331 | delayConnect = 0; | - |
332 | connectTimer->stop(); | - |
333 | delete connectTimer; | - |
334 | connectTimer = 0; | - |
335 | } | 0 |
336 | } executed: } Execution Count:290 | 290 |
337 | | - |
338 | qintptr QLocalSocket::socketDescriptor() const | - |
339 | { | - |
340 | const QLocalSocketPrivate * const d = d_func(); | - |
341 | return d->unixSocket.socketDescriptor(); executed: return d->unixSocket.socketDescriptor(); Execution Count:1 | 1 |
342 | } | - |
343 | | - |
344 | qint64 QLocalSocket::readData(char *data, qint64 c) | - |
345 | { | - |
346 | QLocalSocketPrivate * const d = d_func(); | - |
347 | return d->unixSocket.read(data, c); executed: return d->unixSocket.read(data, c); Execution Count:469 | 469 |
348 | } | - |
349 | | - |
350 | qint64 QLocalSocket::writeData(const char *data, qint64 c) | - |
351 | { | - |
352 | QLocalSocketPrivate * const d = d_func(); | - |
353 | return d->unixSocket.writeData(data, c); executed: return d->unixSocket.writeData(data, c); Execution Count:54 | 54 |
354 | } | - |
355 | | - |
356 | void QLocalSocket::abort() | - |
357 | { | - |
358 | QLocalSocketPrivate * const d = d_func(); | - |
359 | d->unixSocket.abort(); | - |
360 | } executed: } Execution Count:1 | 1 |
361 | | - |
362 | qint64 QLocalSocket::bytesAvailable() const | - |
363 | { | - |
364 | const QLocalSocketPrivate * const d = d_func(); | - |
365 | return QIODevice::bytesAvailable() + d->unixSocket.bytesAvailable(); executed: return QIODevice::bytesAvailable() + d->unixSocket.bytesAvailable(); Execution Count:97 | 97 |
366 | } | - |
367 | | - |
368 | qint64 QLocalSocket::bytesToWrite() const | - |
369 | { | - |
370 | const QLocalSocketPrivate * const d = d_func(); | - |
371 | return d->unixSocket.bytesToWrite(); executed: return d->unixSocket.bytesToWrite(); Execution Count:16 | 16 |
372 | } | - |
373 | | - |
374 | bool QLocalSocket::canReadLine() const | - |
375 | { | - |
376 | const QLocalSocketPrivate * const d = d_func(); | - |
377 | return QIODevice::canReadLine() || d->unixSocket.canReadLine(); executed: return QIODevice::canReadLine() || d->unixSocket.canReadLine(); Execution Count:16 | 16 |
378 | } | - |
379 | | - |
380 | void QLocalSocket::close() | - |
381 | { | - |
382 | QLocalSocketPrivate * const d = d_func(); | - |
383 | d->unixSocket.close(); | - |
384 | d->cancelDelayedConnect(); | - |
385 | if (d->connectingSocket != -1) evaluated: d->connectingSocket != -1 yes Evaluation Count:1 | yes Evaluation Count:214 |
| 1-214 |
386 | ::close(d->connectingSocket); executed: ::close(d->connectingSocket); Execution Count:1 | 1 |
387 | d->connectingSocket = -1; | - |
388 | d->connectingName.clear(); | - |
389 | d->connectingOpenMode = 0; | - |
390 | d->serverName.clear(); | - |
391 | d->fullServerName.clear(); | - |
392 | QIODevice::close(); | - |
393 | } executed: } Execution Count:215 | 215 |
394 | | - |
395 | bool QLocalSocket::waitForBytesWritten(int msecs) | - |
396 | { | - |
397 | QLocalSocketPrivate * const d = d_func(); | - |
398 | return d->unixSocket.waitForBytesWritten(msecs); executed: return d->unixSocket.waitForBytesWritten(msecs); Execution Count:43 | 43 |
399 | } | - |
400 | | - |
401 | bool QLocalSocket::flush() | - |
402 | { | - |
403 | QLocalSocketPrivate * const d = d_func(); | - |
404 | return d->unixSocket.flush(); executed: return d->unixSocket.flush(); Execution Count:16 | 16 |
405 | } | - |
406 | | - |
407 | void QLocalSocket::disconnectFromServer() | - |
408 | { | - |
409 | QLocalSocketPrivate * const d = d_func(); | - |
410 | d->unixSocket.disconnectFromHost(); | - |
411 | } executed: } Execution Count:10 | 10 |
412 | | - |
413 | QLocalSocket::LocalSocketError QLocalSocket::error() const | - |
414 | { | - |
415 | const QLocalSocketPrivate * const d = d_func(); | - |
416 | switch (d->unixSocket.error()) { | - |
417 | case QAbstractSocket::ConnectionRefusedError: | - |
418 | return QLocalSocket::ConnectionRefusedError; never executed: return QLocalSocket::ConnectionRefusedError; | 0 |
419 | case QAbstractSocket::RemoteHostClosedError: | - |
420 | return QLocalSocket::PeerClosedError; executed: return QLocalSocket::PeerClosedError; Execution Count:1 | 1 |
421 | case QAbstractSocket::HostNotFoundError: | - |
422 | return QLocalSocket::ServerNotFoundError; executed: return QLocalSocket::ServerNotFoundError; Execution Count:16 | 16 |
423 | case QAbstractSocket::SocketAccessError: | - |
424 | return QLocalSocket::SocketAccessError; never executed: return QLocalSocket::SocketAccessError; | 0 |
425 | case QAbstractSocket::SocketResourceError: | - |
426 | return QLocalSocket::SocketResourceError; never executed: return QLocalSocket::SocketResourceError; | 0 |
427 | case QAbstractSocket::SocketTimeoutError: | - |
428 | return QLocalSocket::SocketTimeoutError; executed: return QLocalSocket::SocketTimeoutError; Execution Count:6 | 6 |
429 | case QAbstractSocket::DatagramTooLargeError: | - |
430 | return QLocalSocket::DatagramTooLargeError; never executed: return QLocalSocket::DatagramTooLargeError; | 0 |
431 | case QAbstractSocket::NetworkError: | - |
432 | return QLocalSocket::ConnectionError; never executed: return QLocalSocket::ConnectionError; | 0 |
433 | case QAbstractSocket::UnsupportedSocketOperationError: | - |
434 | return QLocalSocket::UnsupportedSocketOperationError; never executed: return QLocalSocket::UnsupportedSocketOperationError; | 0 |
435 | case QAbstractSocket::UnknownSocketError: | - |
436 | return QLocalSocket::UnknownSocketError; executed: return QLocalSocket::UnknownSocketError; Execution Count:7 | 7 |
437 | default: | - |
438 | | - |
439 | | - |
440 | | - |
441 | break; | 0 |
442 | } | - |
443 | return UnknownSocketError; never executed: return UnknownSocketError; | 0 |
444 | } | - |
445 | | - |
446 | bool QLocalSocket::isValid() const | - |
447 | { | - |
448 | const QLocalSocketPrivate * const d = d_func(); | - |
449 | return d->unixSocket.isValid(); executed: return d->unixSocket.isValid(); Execution Count:22 | 22 |
450 | } | - |
451 | | - |
452 | qint64 QLocalSocket::readBufferSize() const | - |
453 | { | - |
454 | const QLocalSocketPrivate * const d = d_func(); | - |
455 | return d->unixSocket.readBufferSize(); executed: return d->unixSocket.readBufferSize(); Execution Count:16 | 16 |
456 | } | - |
457 | | - |
458 | void QLocalSocket::setReadBufferSize(qint64 size) | - |
459 | { | - |
460 | QLocalSocketPrivate * const d = d_func(); | - |
461 | d->unixSocket.setReadBufferSize(size); | - |
462 | } executed: } Execution Count:2 | 2 |
463 | | - |
464 | bool QLocalSocket::waitForConnected(int msec) | - |
465 | { | - |
466 | QLocalSocketPrivate * const d = d_func(); | - |
467 | if (state() != ConnectingState) partially evaluated: state() != ConnectingState yes Evaluation Count:74 | no Evaluation Count:0 |
| 0-74 |
468 | return (state() == ConnectedState); executed: return (state() == ConnectedState); Execution Count:74 | 74 |
469 | | - |
470 | fd_set fds; | - |
471 | do { int __d0, __d1; __asm__ __volatile__ ("cld; rep; " "stosq" : "=c" (__d0), "=D" (__d1) : "a" (0), "0" (sizeof (fd_set) / sizeof (__fd_mask)), "1" (&((&fds)->fds_bits)[0]) : "memory"); } while (0); | 0 |
472 | (((&fds)->fds_bits)[((d->connectingSocket) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) 1 << ((d->connectingSocket) % (8 * (int) sizeof (__fd_mask))))); | - |
473 | | - |
474 | timeval timeout; | - |
475 | timeout.tv_sec = msec / 1000; | - |
476 | timeout.tv_usec = (msec % 1000) * 1000; | - |
477 | | - |
478 | | - |
479 | if (0 == msec) never evaluated: 0 == msec | 0 |
480 | timeout.tv_usec = 1000; never executed: timeout.tv_usec = 1000; | 0 |
481 | | - |
482 | int result = -1; | - |
483 | | - |
484 | QElapsedTimer timer; | - |
485 | timer.start(); | - |
486 | while (state() == ConnectingState never evaluated: state() == ConnectingState | 0 |
487 | && (-1 == msec || timer.elapsed() < msec)) { never evaluated: -1 == msec never evaluated: timer.elapsed() < msec | 0 |
488 | result = ::select(d->connectingSocket + 1, &fds, 0, 0, &timeout); | - |
489 | if (-1 == result && (*__errno_location ()) != 4) { never evaluated: -1 == result never evaluated: (*__errno_location ()) != 4 | 0 |
490 | d->errorOccurred( QLocalSocket::UnknownSocketError, | - |
491 | QLatin1String("QLocalSocket::waitForConnected")); | - |
492 | break; | 0 |
493 | } | - |
494 | if (result > 0) never evaluated: result > 0 | 0 |
495 | d->_q_connectToSocket(); never executed: d->_q_connectToSocket(); | 0 |
496 | } | 0 |
497 | | - |
498 | return (state() == ConnectedState); never executed: return (state() == ConnectedState); | 0 |
499 | } | - |
500 | | - |
501 | bool QLocalSocket::waitForDisconnected(int msecs) | - |
502 | { | - |
503 | QLocalSocketPrivate * const d = d_func(); | - |
504 | if (state() == UnconnectedState) { evaluated: state() == UnconnectedState yes Evaluation Count:2 | yes Evaluation Count:2 |
| 2 |
505 | QMessageLogger("socket/qlocalsocket_unix.cpp", 562, __PRETTY_FUNCTION__).warning() << "QLocalSocket::waitForDisconnected() is not allowed in UnconnectedState"; | - |
506 | return false; executed: return false; Execution Count:2 | 2 |
507 | } | - |
508 | return (d->unixSocket.waitForDisconnected(msecs)); executed: return (d->unixSocket.waitForDisconnected(msecs)); Execution Count:2 | 2 |
509 | } | - |
510 | | - |
511 | bool QLocalSocket::waitForReadyRead(int msecs) | - |
512 | { | - |
513 | QLocalSocketPrivate * const d = d_func(); | - |
514 | if (state() == QLocalSocket::UnconnectedState) evaluated: state() == QLocalSocket::UnconnectedState yes Evaluation Count:7 | yes Evaluation Count:51 |
| 7-51 |
515 | return false; executed: return false; Execution Count:7 | 7 |
516 | return (d->unixSocket.waitForReadyRead(msecs)); executed: return (d->unixSocket.waitForReadyRead(msecs)); Execution Count:51 | 51 |
517 | } | - |
518 | | - |
519 | | - |
520 | | - |
| | |