Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | static bool isProxyError(QAbstractSocket::SocketError error) | - |
9 | { | - |
10 | switch (error) { | - |
11 | case QAbstractSocket::ProxyAuthenticationRequiredError: | - |
12 | case QAbstractSocket::ProxyConnectionRefusedError: | - |
13 | case QAbstractSocket::ProxyConnectionClosedError: | - |
14 | case QAbstractSocket::ProxyConnectionTimeoutError: | - |
15 | case QAbstractSocket::ProxyNotFoundError: | - |
16 | case QAbstractSocket::ProxyProtocolError: | - |
17 | return true; executed: return true; Execution Count:5 | 5 |
18 | default: | - |
19 | return false; executed: return false; Execution Count:10 | 10 |
20 | } | - |
21 | } | 0 |
22 | | - |
23 | | - |
24 | | - |
25 | | - |
26 | | - |
27 | QAbstractSocketPrivate::QAbstractSocketPrivate() | - |
28 | : readSocketNotifierCalled(false), | - |
29 | readSocketNotifierState(false), | - |
30 | readSocketNotifierStateSet(false), | - |
31 | emittedReadyRead(false), | - |
32 | emittedBytesWritten(false), | - |
33 | abortCalled(false), | - |
34 | closeCalled(false), | - |
35 | pendingClose(false), | - |
36 | pauseMode(QAbstractSocket::PauseNever), | - |
37 | port(0), | - |
38 | localPort(0), | - |
39 | peerPort(0), | - |
40 | socketEngine(0), | - |
41 | cachedSocketDescriptor(-1), | - |
42 | readBufferMaxSize(0), | - |
43 | writeBuffer(32768), | - |
44 | isBuffered(false), | - |
45 | blockingTimeout(30000), | - |
46 | connectTimer(0), | - |
47 | disconnectTimer(0), | - |
48 | connectTimeElapsed(0), | - |
49 | hostLookupId(-1), | - |
50 | socketType(QAbstractSocket::UnknownSocketType), | - |
51 | state(QAbstractSocket::UnconnectedState), | - |
52 | socketError(QAbstractSocket::UnknownSocketError), | - |
53 | preferredNetworkLayerProtocol(QAbstractSocket::UnknownNetworkLayerProtocol) | - |
54 | { | - |
55 | } executed: } Execution Count:3146 | 3146 |
56 | | - |
57 | | - |
58 | | - |
59 | | - |
60 | | - |
61 | | - |
62 | QAbstractSocketPrivate::~QAbstractSocketPrivate() | - |
63 | { | - |
64 | } | - |
65 | | - |
66 | | - |
67 | | - |
68 | | - |
69 | | - |
70 | | - |
71 | void QAbstractSocketPrivate::resetSocketLayer() | - |
72 | { | - |
73 | | - |
74 | | - |
75 | | - |
76 | | - |
77 | if (socketEngine) { evaluated: socketEngine yes Evaluation Count:3040 | yes Evaluation Count:3387 |
| 3040-3387 |
78 | socketEngine->close(); | - |
79 | socketEngine->disconnect(); | - |
80 | delete socketEngine; | - |
81 | socketEngine = 0; | - |
82 | cachedSocketDescriptor = -1; | - |
83 | } executed: } Execution Count:3040 | 3040 |
84 | if (connectTimer) evaluated: connectTimer yes Evaluation Count:1250 | yes Evaluation Count:5177 |
| 1250-5177 |
85 | connectTimer->stop(); executed: connectTimer->stop(); Execution Count:1250 | 1250 |
86 | if (disconnectTimer) partially evaluated: disconnectTimer no Evaluation Count:0 | yes Evaluation Count:6427 |
| 0-6427 |
87 | disconnectTimer->stop(); never executed: disconnectTimer->stop(); | 0 |
88 | } executed: } Execution Count:6427 | 6427 |
89 | | - |
90 | | - |
91 | | - |
92 | | - |
93 | | - |
94 | | - |
95 | | - |
96 | bool QAbstractSocketPrivate::initSocketLayer(QAbstractSocket::NetworkLayerProtocol protocol) | - |
97 | { | - |
98 | | - |
99 | | - |
100 | | - |
101 | | - |
102 | | - |
103 | QAbstractSocket * const q = q_func(); | - |
104 | resetSocketLayer(); | - |
105 | socketEngine = QAbstractSocketEngine::createSocketEngine(q->socketType(), proxyInUse, q); | - |
106 | if (!socketEngine) { partially evaluated: !socketEngine no Evaluation Count:0 | yes Evaluation Count:2464 |
| 0-2464 |
107 | socketError = QAbstractSocket::UnsupportedSocketOperationError; | - |
108 | q->setErrorString(QAbstractSocket::tr("Operation on socket is not supported")); | - |
109 | return false; never executed: return false; | 0 |
110 | } | - |
111 | | - |
112 | | - |
113 | socketEngine->setProperty("_q_networksession", q->property("_q_networksession")); | - |
114 | | - |
115 | if (!socketEngine->initialize(q->socketType(), protocol)) { partially evaluated: !socketEngine->initialize(q->socketType(), protocol) no Evaluation Count:0 | yes Evaluation Count:2464 |
| 0-2464 |
116 | | - |
117 | | - |
118 | | - |
119 | | - |
120 | | - |
121 | socketError = socketEngine->error(); | - |
122 | q->setErrorString(socketEngine->errorString()); | - |
123 | return false; never executed: return false; | 0 |
124 | } | - |
125 | | - |
126 | if (threadData->eventDispatcher) partially evaluated: threadData->eventDispatcher yes Evaluation Count:2464 | no Evaluation Count:0 |
| 0-2464 |
127 | socketEngine->setReceiver(this); executed: socketEngine->setReceiver(this); Execution Count:2464 | 2464 |
128 | | - |
129 | | - |
130 | | - |
131 | | - |
132 | | - |
133 | return true; executed: return true; Execution Count:2464 | 2464 |
134 | } | - |
135 | | - |
136 | | - |
137 | | - |
138 | | - |
139 | | - |
140 | | - |
141 | | - |
142 | bool QAbstractSocketPrivate::canReadNotification() | - |
143 | { | - |
144 | QAbstractSocket * const q = q_func(); | - |
145 | | - |
146 | | - |
147 | | - |
148 | | - |
149 | | - |
150 | if (readSocketNotifierCalled) { partially evaluated: readSocketNotifierCalled no Evaluation Count:0 | yes Evaluation Count:22784 |
| 0-22784 |
151 | if (!readSocketNotifierStateSet) { never evaluated: !readSocketNotifierStateSet | 0 |
152 | readSocketNotifierStateSet = true; | - |
153 | readSocketNotifierState = socketEngine->isReadNotificationEnabled(); | - |
154 | socketEngine->setReadNotificationEnabled(false); | - |
155 | } | 0 |
156 | } | 0 |
157 | QScopedValueRollback<bool> rsncrollback(readSocketNotifierCalled); | - |
158 | readSocketNotifierCalled = true; | - |
159 | | - |
160 | if (!isBuffered) evaluated: !isBuffered yes Evaluation Count:6710 | yes Evaluation Count:16074 |
| 6710-16074 |
161 | socketEngine->setReadNotificationEnabled(false); executed: socketEngine->setReadNotificationEnabled(false); Execution Count:6710 | 6710 |
162 | | - |
163 | | - |
164 | qint64 newBytes = 0; | - |
165 | if (isBuffered) { evaluated: isBuffered yes Evaluation Count:16074 | yes Evaluation Count:6710 |
| 6710-16074 |
166 | | - |
167 | if (readBufferMaxSize && buffer.size() >= readBufferMaxSize) { evaluated: readBufferMaxSize yes Evaluation Count:1174 | yes Evaluation Count:14900 |
partially evaluated: buffer.size() >= readBufferMaxSize no Evaluation Count:0 | yes Evaluation Count:1174 |
| 0-14900 |
168 | | - |
169 | | - |
170 | | - |
171 | return false; never executed: return false; | 0 |
172 | } | - |
173 | | - |
174 | | - |
175 | | - |
176 | newBytes = buffer.size(); | - |
177 | if (!readFromSocket()) { evaluated: !readFromSocket() yes Evaluation Count:205 | yes Evaluation Count:15869 |
| 205-15869 |
178 | | - |
179 | | - |
180 | | - |
181 | q->disconnectFromHost(); | - |
182 | return false; executed: return false; Execution Count:205 | 205 |
183 | } | - |
184 | newBytes = buffer.size() - newBytes; | - |
185 | | - |
186 | | - |
187 | if (readBufferMaxSize && buffer.size() == readBufferMaxSize) { evaluated: readBufferMaxSize yes Evaluation Count:1167 | yes Evaluation Count:14702 |
evaluated: buffer.size() == readBufferMaxSize yes Evaluation Count:37 | yes Evaluation Count:1130 |
| 37-14702 |
188 | socketEngine->setReadNotificationEnabled(false); | - |
189 | } executed: } Execution Count:37 | 37 |
190 | } executed: } Execution Count:15869 | 15869 |
191 | | - |
192 | | - |
193 | bool hasData = newBytes > 0 evaluated: newBytes > 0 yes Evaluation Count:15869 | yes Evaluation Count:6710 |
| 6710-15869 |
194 | | - |
195 | || (!isBuffered && socketType != QAbstractSocket::TcpSocket && socketEngine && socketEngine->hasPendingDatagrams()) partially evaluated: !isBuffered yes Evaluation Count:6710 | no Evaluation Count:0 |
evaluated: socketType != QAbstractSocket::TcpSocket yes Evaluation Count:710 | yes Evaluation Count:6000 |
partially evaluated: socketEngine yes Evaluation Count:710 | no Evaluation Count:0 |
evaluated: socketEngine->hasPendingDatagrams() yes Evaluation Count:690 | yes Evaluation Count:20 |
| 0-6710 |
196 | | - |
197 | || (!isBuffered && socketType == QAbstractSocket::TcpSocket && socketEngine) partially evaluated: !isBuffered yes Evaluation Count:6020 | no Evaluation Count:0 |
evaluated: socketType == QAbstractSocket::TcpSocket yes Evaluation Count:6000 | yes Evaluation Count:20 |
partially evaluated: socketEngine yes Evaluation Count:6000 | no Evaluation Count:0 |
| 0-6020 |
198 | ; | - |
199 | | - |
200 | if (!emittedReadyRead && hasData) { partially evaluated: !emittedReadyRead yes Evaluation Count:22579 | no Evaluation Count:0 |
evaluated: hasData yes Evaluation Count:22559 | yes Evaluation Count:20 |
| 0-22579 |
201 | QScopedValueRollback<bool> r(emittedReadyRead); | - |
202 | emittedReadyRead = true; | - |
203 | q->readyRead(); | - |
204 | } executed: } Execution Count:22559 | 22559 |
205 | | - |
206 | | - |
207 | | - |
208 | if (state == QAbstractSocket::UnconnectedState || state == QAbstractSocket::ClosingState) { evaluated: state == QAbstractSocket::UnconnectedState yes Evaluation Count:347 | yes Evaluation Count:22232 |
evaluated: state == QAbstractSocket::ClosingState yes Evaluation Count:1 | yes Evaluation Count:22231 |
| 1-22232 |
209 | | - |
210 | | - |
211 | | - |
212 | return true; executed: return true; Execution Count:348 | 348 |
213 | } | - |
214 | | - |
215 | if (!hasData && socketEngine) evaluated: !hasData yes Evaluation Count:20 | yes Evaluation Count:22211 |
partially evaluated: socketEngine yes Evaluation Count:20 | no Evaluation Count:0 |
| 0-22211 |
216 | socketEngine->setReadNotificationEnabled(true); executed: socketEngine->setReadNotificationEnabled(true); Execution Count:20 | 20 |
217 | | - |
218 | | - |
219 | | - |
220 | if (readSocketNotifierStateSet && socketEngine && partially evaluated: readSocketNotifierStateSet no Evaluation Count:0 | yes Evaluation Count:22231 |
never evaluated: socketEngine | 0-22231 |
221 | readSocketNotifierState != socketEngine->isReadNotificationEnabled()) { never evaluated: readSocketNotifierState != socketEngine->isReadNotificationEnabled() | 0 |
222 | socketEngine->setReadNotificationEnabled(readSocketNotifierState); | - |
223 | readSocketNotifierStateSet = false; | - |
224 | } | 0 |
225 | return true; executed: return true; Execution Count:22231 | 22231 |
226 | } | - |
227 | | - |
228 | | - |
229 | | - |
230 | | - |
231 | | - |
232 | | - |
233 | void QAbstractSocketPrivate::canCloseNotification() | - |
234 | { | - |
235 | QAbstractSocket * const q = q_func(); | - |
236 | | - |
237 | | - |
238 | | - |
239 | | - |
240 | | - |
241 | qint64 newBytes = 0; | - |
242 | if (isBuffered) { never evaluated: isBuffered | 0 |
243 | | - |
244 | newBytes = buffer.size(); | - |
245 | if (!readFromSocket()) { never evaluated: !readFromSocket() | 0 |
246 | q->disconnectFromHost(); | - |
247 | return; | 0 |
248 | } | - |
249 | newBytes = buffer.size() - newBytes; | - |
250 | if (newBytes) { never evaluated: newBytes | 0 |
251 | | - |
252 | | - |
253 | | - |
254 | | - |
255 | | - |
256 | q->readyRead(); | - |
257 | | - |
258 | QMetaObject::invokeMethod(socketEngine, "closeNotification", Qt::QueuedConnection); | - |
259 | } | 0 |
260 | } else if (socketType == QAbstractSocket::TcpSocket && socketEngine) { never evaluated: socketType == QAbstractSocket::TcpSocket never evaluated: socketEngine | 0 |
261 | q->readyRead(); | - |
262 | } | 0 |
263 | } | - |
264 | | - |
265 | | - |
266 | | - |
267 | | - |
268 | | - |
269 | | - |
270 | | - |
271 | bool QAbstractSocketPrivate::canWriteNotification() | - |
272 | { | - |
273 | int tmp = writeBuffer.size(); | - |
274 | flush(); | - |
275 | | - |
276 | if (socketEngine) { evaluated: socketEngine yes Evaluation Count:12359 | yes Evaluation Count:230 |
| 230-12359 |
277 | | - |
278 | | - |
279 | | - |
280 | | - |
281 | if (writeBuffer.isEmpty() && socketEngine->bytesToWrite() == 0) evaluated: writeBuffer.isEmpty() yes Evaluation Count:6944 | yes Evaluation Count:5415 |
evaluated: socketEngine->bytesToWrite() == 0 yes Evaluation Count:6888 | yes Evaluation Count:56 |
| 56-6944 |
282 | socketEngine->setWriteNotificationEnabled(false); executed: socketEngine->setWriteNotificationEnabled(false); Execution Count:6888 | 6888 |
283 | | - |
284 | } executed: } Execution Count:12359 | 12359 |
285 | | - |
286 | return (writeBuffer.size() < tmp); executed: return (writeBuffer.size() < tmp); Execution Count:12589 | 12589 |
287 | } | - |
288 | | - |
289 | | - |
290 | | - |
291 | | - |
292 | | - |
293 | | - |
294 | void QAbstractSocketPrivate::connectionNotification() | - |
295 | { | - |
296 | | - |
297 | | - |
298 | if (state == QAbstractSocket::ConnectingState) { partially evaluated: state == QAbstractSocket::ConnectingState yes Evaluation Count:839 | no Evaluation Count:0 |
| 0-839 |
299 | | - |
300 | | - |
301 | | - |
302 | _q_testConnection(); | - |
303 | } executed: } Execution Count:839 | 839 |
304 | } executed: } Execution Count:839 | 839 |
305 | bool QAbstractSocketPrivate::flush() | - |
306 | { | - |
307 | QAbstractSocket * const q = q_func(); | - |
308 | if (!socketEngine || !socketEngine->isValid() || (writeBuffer.isEmpty() partially evaluated: !socketEngine no Evaluation Count:0 | yes Evaluation Count:24771 |
partially evaluated: !socketEngine->isValid() no Evaluation Count:0 | yes Evaluation Count:24771 |
evaluated: writeBuffer.isEmpty() yes Evaluation Count:710 | yes Evaluation Count:24061 |
| 0-24771 |
309 | && socketEngine->bytesToWrite() == 0)) { evaluated: socketEngine->bytesToWrite() == 0 yes Evaluation Count:693 | yes Evaluation Count:17 |
| 17-693 |
310 | | - |
311 | | - |
312 | | - |
313 | | - |
314 | | - |
315 | | - |
316 | if (state == QAbstractSocket::ClosingState) partially evaluated: state == QAbstractSocket::ClosingState no Evaluation Count:0 | yes Evaluation Count:693 |
| 0-693 |
317 | q->disconnectFromHost(); never executed: q->disconnectFromHost(); | 0 |
318 | | - |
319 | return false; executed: return false; Execution Count:693 | 693 |
320 | } | - |
321 | | - |
322 | int nextSize = writeBuffer.nextDataBlockSize(); | - |
323 | const char *ptr = writeBuffer.readPointer(); | - |
324 | | - |
325 | | - |
326 | qint64 written = socketEngine->write(ptr, nextSize); | - |
327 | if (written < 0) { evaluated: written < 0 yes Evaluation Count:6 | yes Evaluation Count:24072 |
| 6-24072 |
328 | socketError = socketEngine->error(); | - |
329 | q->setErrorString(socketEngine->errorString()); | - |
330 | | - |
331 | | - |
332 | | - |
333 | q->error(socketError); | - |
334 | | - |
335 | q->abort(); | - |
336 | return false; executed: return false; Execution Count:6 | 6 |
337 | } | - |
338 | | - |
339 | | - |
340 | | - |
341 | | - |
342 | | - |
343 | | - |
344 | | - |
345 | writeBuffer.free(written); | - |
346 | if (written > 0) { evaluated: written > 0 yes Evaluation Count:24046 | yes Evaluation Count:26 |
| 26-24046 |
347 | | - |
348 | if (!emittedBytesWritten) { partially evaluated: !emittedBytesWritten yes Evaluation Count:24046 | no Evaluation Count:0 |
| 0-24046 |
349 | QScopedValueRollback<bool> r(emittedBytesWritten); | - |
350 | emittedBytesWritten = true; | - |
351 | q->bytesWritten(written); | - |
352 | } executed: } Execution Count:24046 | 24046 |
353 | } executed: } Execution Count:24046 | 24046 |
354 | | - |
355 | if (writeBuffer.isEmpty() && socketEngine && socketEngine->isWriteNotificationEnabled() evaluated: writeBuffer.isEmpty() yes Evaluation Count:18627 | yes Evaluation Count:5445 |
evaluated: socketEngine yes Evaluation Count:18488 | yes Evaluation Count:139 |
partially evaluated: socketEngine->isWriteNotificationEnabled() yes Evaluation Count:18488 | no Evaluation Count:0 |
| 0-18627 |
356 | && !socketEngine->bytesToWrite()) evaluated: !socketEngine->bytesToWrite() yes Evaluation Count:18424 | yes Evaluation Count:64 |
| 64-18424 |
357 | socketEngine->setWriteNotificationEnabled(false); executed: socketEngine->setWriteNotificationEnabled(false); Execution Count:18424 | 18424 |
358 | if (state == QAbstractSocket::ClosingState) evaluated: state == QAbstractSocket::ClosingState yes Evaluation Count:142 | yes Evaluation Count:23930 |
| 142-23930 |
359 | q->disconnectFromHost(); executed: q->disconnectFromHost(); Execution Count:142 | 142 |
360 | | - |
361 | return true; executed: return true; Execution Count:24072 | 24072 |
362 | } | - |
363 | | - |
364 | | - |
365 | | - |
366 | | - |
367 | | - |
368 | | - |
369 | void QAbstractSocketPrivate::resolveProxy(const QString &hostname, quint16 port) | - |
370 | { | - |
371 | QList<QNetworkProxy> proxies; | - |
372 | | - |
373 | if (proxy.type() != QNetworkProxy::DefaultProxy) { evaluated: proxy.type() != QNetworkProxy::DefaultProxy yes Evaluation Count:946 | yes Evaluation Count:1634 |
| 946-1634 |
374 | | - |
375 | proxies << proxy; | - |
376 | } else { executed: } Execution Count:946 | 946 |
377 | | - |
378 | QNetworkProxyQuery query(hostname, port, QString(), | - |
379 | socketType == QAbstractSocket::TcpSocket ? | - |
380 | QNetworkProxyQuery::TcpSocket : | - |
381 | QNetworkProxyQuery::UdpSocket); | - |
382 | proxies = QNetworkProxyFactory::proxyForQuery(query); | - |
383 | } executed: } Execution Count:1634 | 1634 |
384 | | - |
385 | | - |
386 | for (QForeachContainer<__typeof__(proxies)> _container_(proxies); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QNetworkProxy &p = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - |
387 | if (socketType == QAbstractSocket::UdpSocket && evaluated: socketType == QAbstractSocket::UdpSocket yes Evaluation Count:306 | yes Evaluation Count:2274 |
| 306-2274 |
388 | (p.capabilities() & QNetworkProxy::UdpTunnelingCapability) == 0) partially evaluated: (p.capabilities() & QNetworkProxy::UdpTunnelingCapability) == 0 no Evaluation Count:0 | yes Evaluation Count:306 |
| 0-306 |
389 | continue; never executed: continue; | 0 |
390 | | - |
391 | if (socketType == QAbstractSocket::TcpSocket && evaluated: socketType == QAbstractSocket::TcpSocket yes Evaluation Count:2274 | yes Evaluation Count:306 |
| 306-2274 |
392 | (p.capabilities() & QNetworkProxy::TunnelingCapability) == 0) partially evaluated: (p.capabilities() & QNetworkProxy::TunnelingCapability) == 0 no Evaluation Count:0 | yes Evaluation Count:2274 |
| 0-2274 |
393 | continue; never executed: continue; | 0 |
394 | | - |
395 | proxyInUse = p; | - |
396 | return; executed: return; Execution Count:2580 | 2580 |
397 | } | - |
398 | | - |
399 | | - |
400 | | - |
401 | proxyInUse = QNetworkProxy(); | - |
402 | } | 0 |
403 | | - |
404 | | - |
405 | | - |
406 | | - |
407 | | - |
408 | | - |
409 | | - |
410 | void QAbstractSocketPrivate::startConnectingByName(const QString &host) | - |
411 | { | - |
412 | QAbstractSocket * const q = q_func(); | - |
413 | if (state == QAbstractSocket::ConnectingState || state == QAbstractSocket::ConnectedState) partially evaluated: state == QAbstractSocket::ConnectingState no Evaluation Count:0 | yes Evaluation Count:59 |
partially evaluated: state == QAbstractSocket::ConnectedState no Evaluation Count:0 | yes Evaluation Count:59 |
| 0-59 |
414 | return; | 0 |
415 | | - |
416 | | - |
417 | | - |
418 | | - |
419 | | - |
420 | | - |
421 | state = QAbstractSocket::ConnectingState; | - |
422 | q->stateChanged(state); | - |
423 | | - |
424 | connectTimeElapsed = 0; | - |
425 | | - |
426 | if (initSocketLayer(QAbstractSocket::UnknownNetworkLayerProtocol)) { partially evaluated: initSocketLayer(QAbstractSocket::UnknownNetworkLayerProtocol) yes Evaluation Count:59 | no Evaluation Count:0 |
| 0-59 |
427 | if (socketEngine->connectToHostByName(host, port) || partially evaluated: socketEngine->connectToHostByName(host, port) no Evaluation Count:0 | yes Evaluation Count:59 |
| 0-59 |
428 | socketEngine->state() == QAbstractSocket::ConnectingState) { partially evaluated: socketEngine->state() == QAbstractSocket::ConnectingState yes Evaluation Count:59 | no Evaluation Count:0 |
| 0-59 |
429 | cachedSocketDescriptor = socketEngine->socketDescriptor(); | - |
430 | | - |
431 | return; executed: return; Execution Count:59 | 59 |
432 | } | - |
433 | | - |
434 | | - |
435 | socketError = socketEngine->error(); | - |
436 | q->setErrorString(socketEngine->errorString()); | - |
437 | } | 0 |
438 | | - |
439 | state = QAbstractSocket::UnconnectedState; | - |
440 | q->error(socketError); | - |
441 | q->stateChanged(state); | - |
442 | } | 0 |
443 | void QAbstractSocketPrivate::_q_startConnecting(const QHostInfo &hostInfo) | - |
444 | { | - |
445 | QAbstractSocket * const q = q_func(); | - |
446 | addresses.clear(); | - |
447 | if (state != QAbstractSocket::HostLookupState) partially evaluated: state != QAbstractSocket::HostLookupState no Evaluation Count:0 | yes Evaluation Count:2100 |
| 0-2100 |
448 | return; | 0 |
449 | | - |
450 | if (hostLookupId != -1 && hostLookupId != hostInfo.lookupId()) { evaluated: hostLookupId != -1 yes Evaluation Count:2 | yes Evaluation Count:2098 |
partially evaluated: hostLookupId != hostInfo.lookupId() no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2098 |
451 | QMessageLogger("socket/qabstractsocket.cpp", 1000, __PRETTY_FUNCTION__).warning("QAbstractSocketPrivate::_q_startConnecting() received hostInfo for wrong lookup ID %d expected %d", hostInfo.lookupId(), hostLookupId); | - |
452 | } | 0 |
453 | | - |
454 | | - |
455 | | - |
456 | if (preferredNetworkLayerProtocol == QAbstractSocket::UnknownNetworkLayerProtocol || preferredNetworkLayerProtocol == QAbstractSocket::AnyIPProtocol) { partially evaluated: preferredNetworkLayerProtocol == QAbstractSocket::UnknownNetworkLayerProtocol no Evaluation Count:0 | yes Evaluation Count:2100 |
evaluated: preferredNetworkLayerProtocol == QAbstractSocket::AnyIPProtocol yes Evaluation Count:1505 | yes Evaluation Count:595 |
| 0-2100 |
457 | addresses = hostInfo.addresses(); | - |
458 | } else { executed: } Execution Count:1505 | 1505 |
459 | for (QForeachContainer<__typeof__(hostInfo.addresses())> _container_(hostInfo.addresses()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QHostAddress &address = *_container_.i;; __extension__ ({--_container_.brk; break;})) | - |
460 | if (address.protocol() == preferredNetworkLayerProtocol) evaluated: address.protocol() == preferredNetworkLayerProtocol yes Evaluation Count:595 | yes Evaluation Count:1 |
| 1-595 |
461 | addresses += address; executed: addresses += address; Execution Count:595 | 595 |
462 | } executed: } Execution Count:595 | 595 |
463 | addresses += addresses; | - |
464 | | - |
465 | | - |
466 | | - |
467 | if (addresses.isEmpty()) { evaluated: addresses.isEmpty() yes Evaluation Count:3 | yes Evaluation Count:2097 |
| 3-2097 |
468 | | - |
469 | | - |
470 | | - |
471 | state = QAbstractSocket::UnconnectedState; | - |
472 | socketError = QAbstractSocket::HostNotFoundError; | - |
473 | q->setErrorString(QAbstractSocket::tr("Host not found")); | - |
474 | q->stateChanged(state); | - |
475 | q->error(QAbstractSocket::HostNotFoundError); | - |
476 | return; executed: return; Execution Count:3 | 3 |
477 | } | - |
478 | | - |
479 | | - |
480 | | - |
481 | state = QAbstractSocket::ConnectingState; | - |
482 | q->stateChanged(state); | - |
483 | | - |
484 | | - |
485 | q->hostFound(); | - |
486 | | - |
487 | | - |
488 | connectTimeElapsed = 0; | - |
489 | | - |
490 | | - |
491 | | - |
492 | _q_connectToNextAddress(); | - |
493 | } executed: } Execution Count:2097 | 2097 |
494 | void QAbstractSocketPrivate::_q_connectToNextAddress() | - |
495 | { | - |
496 | QAbstractSocket * const q = q_func(); | - |
497 | do { | - |
498 | | - |
499 | if (addresses.isEmpty()) { evaluated: addresses.isEmpty() yes Evaluation Count:12 | yes Evaluation Count:2102 |
| 12-2102 |
500 | | - |
501 | | - |
502 | | - |
503 | state = QAbstractSocket::UnconnectedState; | - |
504 | if (socketEngine) { partially evaluated: socketEngine yes Evaluation Count:12 | no Evaluation Count:0 |
| 0-12 |
505 | if ((socketEngine->error() == QAbstractSocket::UnknownSocketError | 0-12 |
506 | | 0-12 |
507 | | 0-12 |
508 | | 0-12 |
509 | | 0-12 |
510 | | 0-12 |
511 | ) && socketEngine->state() == QAbstractSocket::ConnectingState) { partially evaluated: (socketEngine->error() == QAbstractSocket::UnknownSocketError ) no Evaluation Count:0 | yes Evaluation Count:12 |
never evaluated: socketEngine->state() == QAbstractSocket::ConnectingState | 0-12 |
512 | socketError = QAbstractSocket::ConnectionRefusedError; | - |
513 | q->setErrorString(QAbstractSocket::tr("Connection refused")); | - |
514 | } else { | 0 |
515 | socketError = socketEngine->error(); | - |
516 | q->setErrorString(socketEngine->errorString()); | - |
517 | } executed: } Execution Count:12 | 12 |
518 | } else { | - |
519 | | - |
520 | | - |
521 | } | 0 |
522 | q->stateChanged(state); | - |
523 | q->error(socketError); | - |
524 | return; executed: return; Execution Count:12 | 12 |
525 | } | - |
526 | | - |
527 | | - |
528 | host = addresses.takeFirst(); | - |
529 | | - |
530 | | - |
531 | | - |
532 | | - |
533 | | - |
534 | if (!initSocketLayer(host.protocol())) { partially evaluated: !initSocketLayer(host.protocol()) no Evaluation Count:0 | yes Evaluation Count:2102 |
| 0-2102 |
535 | | - |
536 | | - |
537 | | - |
538 | | - |
539 | continue; never executed: continue; | 0 |
540 | } | - |
541 | | - |
542 | | - |
543 | | - |
544 | | - |
545 | if (socketEngine->connectToHost(host, port)) { evaluated: socketEngine->connectToHost(host, port) yes Evaluation Count:6 | yes Evaluation Count:2096 |
| 6-2096 |
546 | | - |
547 | fetchConnectionParameters(); | - |
548 | return; executed: return; Execution Count:6 | 6 |
549 | } | - |
550 | | - |
551 | | - |
552 | cachedSocketDescriptor = socketEngine->socketDescriptor(); | - |
553 | | - |
554 | | - |
555 | | - |
556 | if (socketEngine->state() != QAbstractSocket::ConnectingState) { evaluated: socketEngine->state() != QAbstractSocket::ConnectingState yes Evaluation Count:2 | yes Evaluation Count:2094 |
| 2-2094 |
557 | | - |
558 | | - |
559 | | - |
560 | | - |
561 | continue; executed: continue; Execution Count:2 | 2 |
562 | } | - |
563 | | - |
564 | | - |
565 | if (threadData->eventDispatcher) { partially evaluated: threadData->eventDispatcher yes Evaluation Count:2094 | no Evaluation Count:0 |
| 0-2094 |
566 | if (!connectTimer) { evaluated: !connectTimer yes Evaluation Count:1956 | yes Evaluation Count:138 |
| 138-1956 |
567 | connectTimer = new QTimer(q); | - |
568 | QObject::connect(connectTimer, "2""timeout()", | - |
569 | q, "1""_q_abortConnectionAttempt()", | - |
570 | Qt::DirectConnection); | - |
571 | } executed: } Execution Count:1956 | 1956 |
572 | connectTimer->start(30000); | - |
573 | } executed: } Execution Count:2094 | 2094 |
574 | | - |
575 | | - |
576 | | - |
577 | socketEngine->setWriteNotificationEnabled(true); | - |
578 | break; executed: break; Execution Count:2094 | 2094 |
579 | } while (state != QAbstractSocket::ConnectedState); partially evaluated: state != QAbstractSocket::ConnectedState yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
580 | } executed: } Execution Count:2094 | 2094 |
581 | | - |
582 | | - |
583 | | - |
584 | | - |
585 | | - |
586 | | - |
587 | void QAbstractSocketPrivate::_q_testConnection() | - |
588 | { | - |
589 | if (socketEngine) { partially evaluated: socketEngine yes Evaluation Count:1261 | no Evaluation Count:0 |
| 0-1261 |
590 | if (threadData->eventDispatcher) { partially evaluated: threadData->eventDispatcher yes Evaluation Count:1261 | no Evaluation Count:0 |
| 0-1261 |
591 | if (connectTimer) evaluated: connectTimer yes Evaluation Count:1202 | yes Evaluation Count:59 |
| 59-1202 |
592 | connectTimer->stop(); executed: connectTimer->stop(); Execution Count:1202 | 1202 |
593 | } executed: } Execution Count:1261 | 1261 |
594 | | - |
595 | if (socketEngine->state() == QAbstractSocket::ConnectedState) { evaluated: socketEngine->state() == QAbstractSocket::ConnectedState yes Evaluation Count:1246 | yes Evaluation Count:15 |
| 15-1246 |
596 | | - |
597 | | - |
598 | fetchConnectionParameters(); | - |
599 | if (pendingClose) { partially evaluated: pendingClose no Evaluation Count:0 | yes Evaluation Count:1246 |
| 0-1246 |
600 | q_func()->disconnectFromHost(); | - |
601 | pendingClose = false; | - |
602 | } | 0 |
603 | return; executed: return; Execution Count:1246 | 1246 |
604 | } | - |
605 | | - |
606 | | - |
607 | if (isProxyError(socketEngine->error())) evaluated: isProxyError(socketEngine->error()) yes Evaluation Count:5 | yes Evaluation Count:10 |
| 5-10 |
608 | addresses.clear(); executed: addresses.clear(); Execution Count:5 | 5 |
609 | } executed: } Execution Count:15 | 15 |
610 | | - |
611 | if (threadData->eventDispatcher) { partially evaluated: threadData->eventDispatcher yes Evaluation Count:15 | no Evaluation Count:0 |
| 0-15 |
612 | if (connectTimer) evaluated: connectTimer yes Evaluation Count:8 | yes Evaluation Count:7 |
| 7-8 |
613 | connectTimer->stop(); executed: connectTimer->stop(); Execution Count:8 | 8 |
614 | } executed: } Execution Count:15 | 15 |
615 | | - |
616 | | - |
617 | | - |
618 | | - |
619 | | - |
620 | _q_connectToNextAddress(); | - |
621 | } executed: } Execution Count:15 | 15 |
622 | void QAbstractSocketPrivate::_q_abortConnectionAttempt() | - |
623 | { | - |
624 | QAbstractSocket * const q = q_func(); | - |
625 | | - |
626 | | - |
627 | | - |
628 | if (socketEngine) never evaluated: socketEngine | 0 |
629 | socketEngine->setWriteNotificationEnabled(false); never executed: socketEngine->setWriteNotificationEnabled(false); | 0 |
630 | | - |
631 | connectTimer->stop(); | - |
632 | | - |
633 | if (addresses.isEmpty()) { never evaluated: addresses.isEmpty() | 0 |
634 | state = QAbstractSocket::UnconnectedState; | - |
635 | socketError = QAbstractSocket::SocketTimeoutError; | - |
636 | q->setErrorString(QAbstractSocket::tr("Connection timed out")); | - |
637 | q->stateChanged(state); | - |
638 | q->error(socketError); | - |
639 | } else { | 0 |
640 | _q_connectToNextAddress(); | - |
641 | } | 0 |
642 | } | - |
643 | | - |
644 | void QAbstractSocketPrivate::_q_forceDisconnect() | - |
645 | { | - |
646 | QAbstractSocket * const q = q_func(); | - |
647 | if (socketEngine && socketEngine->isValid() && state == QAbstractSocket::ClosingState) { never evaluated: socketEngine never evaluated: socketEngine->isValid() never evaluated: state == QAbstractSocket::ClosingState | 0 |
648 | socketEngine->close(); | - |
649 | q->disconnectFromHost(); | - |
650 | } | 0 |
651 | } | 0 |
652 | | - |
653 | | - |
654 | | - |
655 | | - |
656 | | - |
657 | | - |
658 | bool QAbstractSocketPrivate::readFromSocket() | - |
659 | { | - |
660 | QAbstractSocket * const q = q_func(); | - |
661 | | - |
662 | qint64 bytesToRead = socketEngine->bytesAvailable(); | - |
663 | if (bytesToRead == 0) { evaluated: bytesToRead == 0 yes Evaluation Count:205 | yes Evaluation Count:15869 |
| 205-15869 |
664 | | - |
665 | | - |
666 | | - |
667 | | - |
668 | | - |
669 | | - |
670 | | - |
671 | bytesToRead = 4096; | - |
672 | } executed: } Execution Count:205 | 205 |
673 | if (readBufferMaxSize && bytesToRead > (readBufferMaxSize - buffer.size())) evaluated: readBufferMaxSize yes Evaluation Count:1174 | yes Evaluation Count:14900 |
evaluated: bytesToRead > (readBufferMaxSize - buffer.size()) yes Evaluation Count:36 | yes Evaluation Count:1138 |
| 36-14900 |
674 | bytesToRead = readBufferMaxSize - buffer.size(); executed: bytesToRead = readBufferMaxSize - buffer.size(); Execution Count:36 | 36 |
675 | | - |
676 | | - |
677 | | - |
678 | | - |
679 | | - |
680 | | - |
681 | | - |
682 | char *ptr = buffer.reserve(bytesToRead); | - |
683 | qint64 readBytes = socketEngine->read(ptr, bytesToRead); | - |
684 | if (readBytes == -2) { partially evaluated: readBytes == -2 no Evaluation Count:0 | yes Evaluation Count:16074 |
| 0-16074 |
685 | | - |
686 | buffer.chop(bytesToRead); | - |
687 | return true; never executed: return true; | 0 |
688 | } | - |
689 | buffer.chop(int(bytesToRead - (readBytes < 0 ? qint64(0) : readBytes))); | - |
690 | | - |
691 | | - |
692 | | - |
693 | | - |
694 | | - |
695 | if (!socketEngine->isValid()) { evaluated: !socketEngine->isValid() yes Evaluation Count:205 | yes Evaluation Count:15869 |
| 205-15869 |
696 | socketError = socketEngine->error(); | - |
697 | q->setErrorString(socketEngine->errorString()); | - |
698 | q->error(socketError); | - |
699 | | - |
700 | | - |
701 | | - |
702 | | - |
703 | resetSocketLayer(); | - |
704 | return false; executed: return false; Execution Count:205 | 205 |
705 | } | - |
706 | | - |
707 | return true; executed: return true; Execution Count:15869 | 15869 |
708 | } | - |
709 | | - |
710 | | - |
711 | | - |
712 | | - |
713 | | - |
714 | void QAbstractSocketPrivate::fetchConnectionParameters() | - |
715 | { | - |
716 | QAbstractSocket * const q = q_func(); | - |
717 | | - |
718 | peerName = hostName; | - |
719 | if (socketEngine) { partially evaluated: socketEngine yes Evaluation Count:1252 | no Evaluation Count:0 |
| 0-1252 |
720 | socketEngine->setReadNotificationEnabled(true); | - |
721 | socketEngine->setWriteNotificationEnabled(true); | - |
722 | localPort = socketEngine->localPort(); | - |
723 | peerPort = socketEngine->peerPort(); | - |
724 | localAddress = socketEngine->localAddress(); | - |
725 | peerAddress = socketEngine->peerAddress(); | - |
726 | cachedSocketDescriptor = socketEngine->socketDescriptor(); | - |
727 | } executed: } Execution Count:1252 | 1252 |
728 | | - |
729 | state = QAbstractSocket::ConnectedState; | - |
730 | q->stateChanged(state); | - |
731 | q->connected(); | - |
732 | | - |
733 | | - |
734 | | - |
735 | | - |
736 | | - |
737 | } executed: } Execution Count:1252 | 1252 |
738 | | - |
739 | | - |
740 | void QAbstractSocketPrivate::pauseSocketNotifiers(QAbstractSocket *socket) | - |
741 | { | - |
742 | QAbstractSocketEngine *socketEngine = socket->d_func()->socketEngine; | - |
743 | if (!socketEngine) evaluated: !socketEngine yes Evaluation Count:2 | yes Evaluation Count:251 |
| 2-251 |
744 | return; executed: return; Execution Count:2 | 2 |
745 | socket->d_func()->prePauseReadSocketNotifierState = socketEngine->isReadNotificationEnabled(); | - |
746 | socket->d_func()->prePauseWriteSocketNotifierState = socketEngine->isWriteNotificationEnabled(); | - |
747 | socket->d_func()->prePauseExceptionSocketNotifierState = socketEngine->isExceptionNotificationEnabled(); | - |
748 | socketEngine->setReadNotificationEnabled(false); | - |
749 | socketEngine->setWriteNotificationEnabled(false); | - |
750 | socketEngine->setExceptionNotificationEnabled(false); | - |
751 | } executed: } Execution Count:251 | 251 |
752 | | - |
753 | void QAbstractSocketPrivate::resumeSocketNotifiers(QAbstractSocket *socket) | - |
754 | { | - |
755 | QAbstractSocketEngine *socketEngine = socket->d_func()->socketEngine; | - |
756 | if (!socketEngine) evaluated: !socketEngine yes Evaluation Count:2 | yes Evaluation Count:251 |
| 2-251 |
757 | return; executed: return; Execution Count:2 | 2 |
758 | socketEngine->setReadNotificationEnabled(socket->d_func()->prePauseReadSocketNotifierState); | - |
759 | socketEngine->setWriteNotificationEnabled(socket->d_func()->prePauseWriteSocketNotifierState); | - |
760 | socketEngine->setExceptionNotificationEnabled(socket->d_func()->prePauseExceptionSocketNotifierState); | - |
761 | } executed: } Execution Count:251 | 251 |
762 | | - |
763 | QAbstractSocketEngine* QAbstractSocketPrivate::getSocketEngine(QAbstractSocket *socket) | - |
764 | { | - |
765 | return socket->d_func()->socketEngine; never executed: return socket->d_func()->socketEngine; | 0 |
766 | } | - |
767 | | - |
768 | | - |
769 | | - |
770 | | - |
771 | | - |
772 | | - |
773 | | - |
774 | QAbstractSocket::QAbstractSocket(SocketType socketType, | - |
775 | QAbstractSocketPrivate &dd, QObject *parent) | - |
776 | : QIODevice(dd, parent) | - |
777 | { | - |
778 | QAbstractSocketPrivate * const d = d_func(); | - |
779 | | - |
780 | | - |
781 | | - |
782 | | - |
783 | | - |
784 | d->socketType = socketType; | - |
785 | } executed: } Execution Count:3144 | 3144 |
786 | | - |
787 | | - |
788 | | - |
789 | | - |
790 | | - |
791 | | - |
792 | | - |
793 | QAbstractSocket::QAbstractSocket(SocketType socketType, QObject *parent) | - |
794 | : QIODevice(*new QAbstractSocketPrivate, parent) | - |
795 | { | - |
796 | QAbstractSocketPrivate * const d = d_func(); | - |
797 | | - |
798 | | - |
799 | | - |
800 | d->socketType = socketType; | - |
801 | } executed: } Execution Count:1 | 1 |
802 | | - |
803 | | - |
804 | | - |
805 | | - |
806 | QAbstractSocket::~QAbstractSocket() | - |
807 | { | - |
808 | QAbstractSocketPrivate * const d = d_func(); | - |
809 | | - |
810 | | - |
811 | | - |
812 | if (d->state != UnconnectedState) evaluated: d->state != UnconnectedState yes Evaluation Count:1629 | yes Evaluation Count:1513 |
| 1513-1629 |
813 | abort(); executed: abort(); Execution Count:1629 | 1629 |
814 | } executed: } Execution Count:3142 | 3142 |
815 | void QAbstractSocket::resume() | - |
816 | { | - |
817 | QAbstractSocketPrivate::resumeSocketNotifiers(this); | - |
818 | } | 0 |
819 | QAbstractSocket::PauseModes QAbstractSocket::pauseMode() const | - |
820 | { | - |
821 | return d_func()->pauseMode; executed: return d_func()->pauseMode; Execution Count:9 | 9 |
822 | } | - |
823 | void QAbstractSocket::setPauseMode(PauseModes pauseMode) | - |
824 | { | - |
825 | d_func()->pauseMode = pauseMode; | - |
826 | } | 0 |
827 | bool QAbstractSocket::bind(const QHostAddress &address, quint16 port, BindMode mode) | - |
828 | { | - |
829 | QAbstractSocketPrivate * const d = d_func(); | - |
830 | | - |
831 | | - |
832 | if (!d->socketEngine || !d->socketEngine->isValid()) { evaluated: !d->socketEngine yes Evaluation Count:286 | yes Evaluation Count:19 |
partially evaluated: !d->socketEngine->isValid() no Evaluation Count:0 | yes Evaluation Count:19 |
| 0-286 |
833 | QHostAddress nullAddress; | - |
834 | d->resolveProxy(nullAddress.toString(), port); | - |
835 | | - |
836 | QAbstractSocket::NetworkLayerProtocol protocol = address.protocol(); | - |
837 | if (protocol == QAbstractSocket::UnknownNetworkLayerProtocol) partially evaluated: protocol == QAbstractSocket::UnknownNetworkLayerProtocol no Evaluation Count:0 | yes Evaluation Count:286 |
| 0-286 |
838 | protocol = nullAddress.protocol(); never executed: protocol = nullAddress.protocol(); | 0 |
839 | | - |
840 | if (!d->initSocketLayer(protocol)) partially evaluated: !d->initSocketLayer(protocol) no Evaluation Count:0 | yes Evaluation Count:286 |
| 0-286 |
841 | return false; never executed: return false; | 0 |
842 | } executed: } Execution Count:286 | 286 |
843 | | - |
844 | if (mode != DefaultForPlatform) { evaluated: mode != DefaultForPlatform yes Evaluation Count:3 | yes Evaluation Count:302 |
| 3-302 |
845 | | - |
846 | if ((mode & ShareAddress) || (mode & ReuseAddressHint)) evaluated: (mode & ShareAddress) yes Evaluation Count:1 | yes Evaluation Count:2 |
partially evaluated: (mode & ReuseAddressHint) yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
847 | d->socketEngine->setOption(QAbstractSocketEngine::AddressReusable, 1); executed: d->socketEngine->setOption(QAbstractSocketEngine::AddressReusable, 1); Execution Count:3 | 3 |
848 | else | - |
849 | d->socketEngine->setOption(QAbstractSocketEngine::AddressReusable, 0); never executed: d->socketEngine->setOption(QAbstractSocketEngine::AddressReusable, 0); | 0 |
850 | } | - |
851 | bool result = d->socketEngine->bind(address, port); | - |
852 | d->cachedSocketDescriptor = d->socketEngine->socketDescriptor(); | - |
853 | | - |
854 | if (!result) { evaluated: !result yes Evaluation Count:27 | yes Evaluation Count:278 |
| 27-278 |
855 | d->socketError = d->socketEngine->error(); | - |
856 | setErrorString(d->socketEngine->errorString()); | - |
857 | error(d->socketError); | - |
858 | return false; executed: return false; Execution Count:27 | 27 |
859 | } | - |
860 | | - |
861 | d->state = BoundState; | - |
862 | d->localAddress = d->socketEngine->localAddress(); | - |
863 | d->localPort = d->socketEngine->localPort(); | - |
864 | | - |
865 | stateChanged(d->state); | - |
866 | d->socketEngine->setReadNotificationEnabled(true); | - |
867 | return true; executed: return true; Execution Count:278 | 278 |
868 | } | - |
869 | bool QAbstractSocket::bind(quint16 port, BindMode mode) | - |
870 | { | - |
871 | return bind(QHostAddress::Any, port, mode); executed: return bind(QHostAddress::Any, port, mode); Execution Count:121 | 121 |
872 | } | - |
873 | bool QAbstractSocket::isValid() const | - |
874 | { | - |
875 | return d_func()->socketEngine ? d_func()->socketEngine->isValid() : isOpen(); executed: return d_func()->socketEngine ? d_func()->socketEngine->isValid() : isOpen(); Execution Count:3341915 | 3341915 |
876 | } | - |
877 | void QAbstractSocket::connectToHost(const QString &hostName, quint16 port, | - |
878 | OpenMode openMode, | - |
879 | NetworkLayerProtocol protocol) | - |
880 | { | - |
881 | QAbstractSocketPrivate * const d = d_func(); | - |
882 | | - |
883 | | - |
884 | | - |
885 | | - |
886 | | - |
887 | if (d->state == ConnectedState || d->state == ConnectingState partially evaluated: d->state == ConnectedState no Evaluation Count:0 | yes Evaluation Count:2277 |
partially evaluated: d->state == ConnectingState no Evaluation Count:0 | yes Evaluation Count:2277 |
| 0-2277 |
888 | || d->state == ClosingState || d->state == HostLookupState) { partially evaluated: d->state == ClosingState no Evaluation Count:0 | yes Evaluation Count:2277 |
partially evaluated: d->state == HostLookupState no Evaluation Count:0 | yes Evaluation Count:2277 |
| 0-2277 |
889 | QMessageLogger("socket/qabstractsocket.cpp", 1584, __PRETTY_FUNCTION__).warning("QAbstractSocket::connectToHost() called when already looking up or connecting/connected to \"%s\"", QString(hostName).toLocal8Bit().constData()); | - |
890 | d->socketError = QAbstractSocket::OperationError; | - |
891 | setErrorString(QAbstractSocket::tr("Trying to connect while connection is in progress")); | - |
892 | error(d->socketError); | - |
893 | return; | 0 |
894 | } | - |
895 | | - |
896 | d->preferredNetworkLayerProtocol = protocol; | - |
897 | d->hostName = hostName; | - |
898 | d->port = port; | - |
899 | d->state = UnconnectedState; | - |
900 | d->buffer.clear(); | - |
901 | d->writeBuffer.clear(); | - |
902 | d->abortCalled = false; | - |
903 | d->closeCalled = false; | - |
904 | d->pendingClose = false; | - |
905 | d->localPort = 0; | - |
906 | d->peerPort = 0; | - |
907 | d->localAddress.clear(); | - |
908 | d->peerAddress.clear(); | - |
909 | d->peerName = hostName; | - |
910 | if (d->hostLookupId != -1) { partially evaluated: d->hostLookupId != -1 no Evaluation Count:0 | yes Evaluation Count:2277 |
| 0-2277 |
911 | QHostInfo::abortHostLookup(d->hostLookupId); | - |
912 | d->hostLookupId = -1; | - |
913 | } | 0 |
914 | | - |
915 | | - |
916 | | - |
917 | d->resolveProxy(hostName, port); | - |
918 | if (d->proxyInUse.type() == QNetworkProxy::DefaultProxy) { partially evaluated: d->proxyInUse.type() == QNetworkProxy::DefaultProxy no Evaluation Count:0 | yes Evaluation Count:2277 |
| 0-2277 |
919 | | - |
920 | d->socketError = QAbstractSocket::UnsupportedSocketOperationError; | - |
921 | setErrorString(QAbstractSocket::tr("Operation on socket is not supported")); | - |
922 | error(d->socketError); | - |
923 | return; | 0 |
924 | } | - |
925 | | - |
926 | | - |
927 | if (openMode & QIODevice::Unbuffered) evaluated: openMode & QIODevice::Unbuffered yes Evaluation Count:425 | yes Evaluation Count:1852 |
| 425-1852 |
928 | d->isBuffered = false; executed: d->isBuffered = false; Execution Count:425 | 425 |
929 | else if (!d_func()->isBuffered) evaluated: !d_func()->isBuffered yes Evaluation Count:6 | yes Evaluation Count:1846 |
| 6-1846 |
930 | openMode |= QAbstractSocket::Unbuffered; executed: openMode |= QAbstractSocket::Unbuffered; Execution Count:6 | 6 |
931 | | - |
932 | QIODevice::open(openMode); | - |
933 | d->state = HostLookupState; | - |
934 | stateChanged(d->state); | - |
935 | | - |
936 | QHostAddress temp; | - |
937 | if (temp.setAddress(hostName)) { evaluated: temp.setAddress(hostName) yes Evaluation Count:519 | yes Evaluation Count:1758 |
| 519-1758 |
938 | QHostInfo info; | - |
939 | info.setAddresses(QList<QHostAddress>() << temp); | - |
940 | d->_q_startConnecting(info); | - |
941 | | - |
942 | } else if (d->proxyInUse.capabilities() & QNetworkProxy::HostNameLookupCapability) { executed: } Execution Count:519 evaluated: d->proxyInUse.capabilities() & QNetworkProxy::HostNameLookupCapability yes Evaluation Count:59 | yes Evaluation Count:1699 |
| 59-1699 |
943 | | - |
944 | d->startConnectingByName(hostName); | - |
945 | return; executed: return; Execution Count:59 | 59 |
946 | | - |
947 | } else { | - |
948 | if (d->threadData->eventDispatcher) { partially evaluated: d->threadData->eventDispatcher yes Evaluation Count:1699 | no Evaluation Count:0 |
| 0-1699 |
949 | | - |
950 | | - |
951 | bool immediateResultValid = false; | - |
952 | QHostInfo hostInfo = qt_qhostinfo_lookup(hostName, | - |
953 | this, | - |
954 | "1""_q_startConnecting(QHostInfo)", | - |
955 | &immediateResultValid, | - |
956 | &d->hostLookupId); | - |
957 | if (immediateResultValid) { evaluated: immediateResultValid yes Evaluation Count:1577 | yes Evaluation Count:122 |
| 122-1577 |
958 | d->hostLookupId = -1; | - |
959 | d->_q_startConnecting(hostInfo); | - |
960 | } executed: } Execution Count:1577 | 1577 |
961 | } executed: } Execution Count:1699 | 1699 |
962 | } executed: } Execution Count:1699 | 1699 |
963 | | - |
964 | | - |
965 | | - |
966 | | - |
967 | | - |
968 | | - |
969 | | - |
970 | } | - |
971 | | - |
972 | | - |
973 | | - |
974 | | - |
975 | | - |
976 | void QAbstractSocket::connectToHost(const QHostAddress &address, quint16 port, | - |
977 | OpenMode openMode) | - |
978 | { | - |
979 | | - |
980 | | - |
981 | | - |
982 | | - |
983 | connectToHost(address.toString(), port, openMode); | - |
984 | } executed: } Execution Count:54 | 54 |
985 | qint64 QAbstractSocket::bytesToWrite() const | - |
986 | { | - |
987 | const QAbstractSocketPrivate * const d = d_func(); | - |
988 | | - |
989 | | - |
990 | | - |
991 | return (qint64)d->writeBuffer.size(); executed: return (qint64)d->writeBuffer.size(); Execution Count:17851 | 17851 |
992 | } | - |
993 | | - |
994 | | - |
995 | | - |
996 | | - |
997 | | - |
998 | | - |
999 | qint64 QAbstractSocket::bytesAvailable() const | - |
1000 | { | - |
1001 | const QAbstractSocketPrivate * const d = d_func(); | - |
1002 | qint64 available = QIODevice::bytesAvailable(); | - |
1003 | | - |
1004 | if (!d->isBuffered && d->socketEngine && d->socketEngine->isValid()) evaluated: !d->isBuffered yes Evaluation Count:17559 | yes Evaluation Count:14948 |
evaluated: d->socketEngine yes Evaluation Count:17512 | yes Evaluation Count:47 |
partially evaluated: d->socketEngine->isValid() yes Evaluation Count:17512 | no Evaluation Count:0 |
| 0-17559 |
1005 | available += d->socketEngine->bytesAvailable(); executed: available += d->socketEngine->bytesAvailable(); Execution Count:17512 | 17512 |
1006 | | - |
1007 | | - |
1008 | | - |
1009 | | - |
1010 | return available; executed: return available; Execution Count:32507 | 32507 |
1011 | } | - |
1012 | | - |
1013 | | - |
1014 | | - |
1015 | | - |
1016 | | - |
1017 | | - |
1018 | | - |
1019 | quint16 QAbstractSocket::localPort() const | - |
1020 | { | - |
1021 | const QAbstractSocketPrivate * const d = d_func(); | - |
1022 | return d->localPort; executed: return d->localPort; Execution Count:423 | 423 |
1023 | } | - |
1024 | QHostAddress QAbstractSocket::localAddress() const | - |
1025 | { | - |
1026 | const QAbstractSocketPrivate * const d = d_func(); | - |
1027 | return d->localAddress; executed: return d->localAddress; Execution Count:716 | 716 |
1028 | } | - |
1029 | | - |
1030 | | - |
1031 | | - |
1032 | | - |
1033 | | - |
1034 | | - |
1035 | | - |
1036 | quint16 QAbstractSocket::peerPort() const | - |
1037 | { | - |
1038 | const QAbstractSocketPrivate * const d = d_func(); | - |
1039 | return d->peerPort; executed: return d->peerPort; Execution Count:133 | 133 |
1040 | } | - |
1041 | | - |
1042 | | - |
1043 | | - |
1044 | | - |
1045 | | - |
1046 | | - |
1047 | | - |
1048 | QHostAddress QAbstractSocket::peerAddress() const | - |
1049 | { | - |
1050 | const QAbstractSocketPrivate * const d = d_func(); | - |
1051 | return d->peerAddress; executed: return d->peerAddress; Execution Count:127 | 127 |
1052 | } | - |
1053 | | - |
1054 | | - |
1055 | | - |
1056 | | - |
1057 | | - |
1058 | | - |
1059 | | - |
1060 | QString QAbstractSocket::peerName() const | - |
1061 | { | - |
1062 | const QAbstractSocketPrivate * const d = d_func(); | - |
1063 | return d->peerName.isEmpty() ? d->hostName : d->peerName; executed: return d->peerName.isEmpty() ? d->hostName : d->peerName; Execution Count:327 | 327 |
1064 | } | - |
1065 | | - |
1066 | | - |
1067 | | - |
1068 | | - |
1069 | | - |
1070 | | - |
1071 | | - |
1072 | bool QAbstractSocket::canReadLine() const | - |
1073 | { | - |
1074 | bool hasLine = d_func()->buffer.canReadLine(); | - |
1075 | | - |
1076 | | - |
1077 | | - |
1078 | | - |
1079 | return hasLine || QIODevice::canReadLine(); executed: return hasLine || QIODevice::canReadLine(); Execution Count:1081 | 1081 |
1080 | } | - |
1081 | qintptr QAbstractSocket::socketDescriptor() const | - |
1082 | { | - |
1083 | const QAbstractSocketPrivate * const d = d_func(); | - |
1084 | return d->cachedSocketDescriptor; executed: return d->cachedSocketDescriptor; Execution Count:290 | 290 |
1085 | } | - |
1086 | bool QAbstractSocket::setSocketDescriptor(qintptr socketDescriptor, SocketState socketState, | - |
1087 | OpenMode openMode) | - |
1088 | { | - |
1089 | QAbstractSocketPrivate * const d = d_func(); | - |
1090 | | - |
1091 | d->resetSocketLayer(); | - |
1092 | d->socketEngine = QAbstractSocketEngine::createSocketEngine(socketDescriptor, this); | - |
1093 | if (!d->socketEngine) { partially evaluated: !d->socketEngine no Evaluation Count:0 | yes Evaluation Count:612 |
| 0-612 |
1094 | d->socketError = UnsupportedSocketOperationError; | - |
1095 | setErrorString(tr("Operation on socket is not supported")); | - |
1096 | return false; never executed: return false; | 0 |
1097 | } | - |
1098 | | - |
1099 | | - |
1100 | d->socketEngine->setProperty("_q_networksession", property("_q_networksession")); | - |
1101 | | - |
1102 | bool result = d->socketEngine->initialize(socketDescriptor, socketState); | - |
1103 | if (!result) { evaluated: !result yes Evaluation Count:1 | yes Evaluation Count:611 |
| 1-611 |
1104 | d->socketError = d->socketEngine->error(); | - |
1105 | setErrorString(d->socketEngine->errorString()); | - |
1106 | return false; executed: return false; Execution Count:1 | 1 |
1107 | } | - |
1108 | | - |
1109 | if (d->threadData->eventDispatcher) partially evaluated: d->threadData->eventDispatcher yes Evaluation Count:611 | no Evaluation Count:0 |
| 0-611 |
1110 | d->socketEngine->setReceiver(d); executed: d->socketEngine->setReceiver(d); Execution Count:611 | 611 |
1111 | | - |
1112 | QIODevice::open(openMode); | - |
1113 | | - |
1114 | if (d->state != socketState) { partially evaluated: d->state != socketState yes Evaluation Count:611 | no Evaluation Count:0 |
| 0-611 |
1115 | d->state = socketState; | - |
1116 | stateChanged(d->state); | - |
1117 | } executed: } Execution Count:611 | 611 |
1118 | | - |
1119 | d->pendingClose = false; | - |
1120 | d->socketEngine->setReadNotificationEnabled(true); | - |
1121 | d->localPort = d->socketEngine->localPort(); | - |
1122 | d->peerPort = d->socketEngine->peerPort(); | - |
1123 | d->localAddress = d->socketEngine->localAddress(); | - |
1124 | d->peerAddress = d->socketEngine->peerAddress(); | - |
1125 | d->cachedSocketDescriptor = socketDescriptor; | - |
1126 | | - |
1127 | return true; executed: return true; Execution Count:611 | 611 |
1128 | } | - |
1129 | | - |
1130 | | - |
1131 | | - |
1132 | | - |
1133 | | - |
1134 | | - |
1135 | | - |
1136 | void QAbstractSocket::setSocketOption(QAbstractSocket::SocketOption option, const QVariant &value) | - |
1137 | { | - |
1138 | if (!d_func()->socketEngine) partially evaluated: !d_func()->socketEngine no Evaluation Count:0 | yes Evaluation Count:790 |
| 0-790 |
1139 | return; | 0 |
1140 | | - |
1141 | switch (option) { | - |
1142 | case LowDelayOption: | - |
1143 | d_func()->socketEngine->setOption(QAbstractSocketEngine::LowDelayOption, value.toInt()); | - |
1144 | break; executed: break; Execution Count:36 | 36 |
1145 | | - |
1146 | case KeepAliveOption: | - |
1147 | d_func()->socketEngine->setOption(QAbstractSocketEngine::KeepAliveOption, value.toInt()); | - |
1148 | break; executed: break; Execution Count:702 | 702 |
1149 | | - |
1150 | case MulticastTtlOption: | - |
1151 | d_func()->socketEngine->setOption(QAbstractSocketEngine::MulticastTtlOption, value.toInt()); | - |
1152 | break; executed: break; Execution Count:24 | 24 |
1153 | | - |
1154 | case MulticastLoopbackOption: | - |
1155 | d_func()->socketEngine->setOption(QAbstractSocketEngine::MulticastLoopbackOption, value.toInt()); | - |
1156 | break; executed: break; Execution Count:28 | 28 |
1157 | | - |
1158 | case TypeOfServiceOption: | - |
1159 | d_func()->socketEngine->setOption(QAbstractSocketEngine::TypeOfServiceOption, value.toInt()); | - |
1160 | break; | 0 |
1161 | } | - |
1162 | } executed: } Execution Count:790 | 790 |
1163 | | - |
1164 | | - |
1165 | | - |
1166 | | - |
1167 | | - |
1168 | | - |
1169 | | - |
1170 | QVariant QAbstractSocket::socketOption(QAbstractSocket::SocketOption option) | - |
1171 | { | - |
1172 | if (!d_func()->socketEngine) partially evaluated: !d_func()->socketEngine no Evaluation Count:0 | yes Evaluation Count:52 |
| 0-52 |
1173 | return QVariant(); never executed: return QVariant(); | 0 |
1174 | | - |
1175 | int ret = -1; | - |
1176 | switch (option) { | - |
1177 | case LowDelayOption: | - |
1178 | ret = d_func()->socketEngine->option(QAbstractSocketEngine::LowDelayOption); | - |
1179 | break; | 0 |
1180 | | - |
1181 | case KeepAliveOption: | - |
1182 | ret = d_func()->socketEngine->option(QAbstractSocketEngine::KeepAliveOption); | - |
1183 | break; | 0 |
1184 | | - |
1185 | case MulticastTtlOption: | - |
1186 | ret = d_func()->socketEngine->option(QAbstractSocketEngine::MulticastTtlOption); | - |
1187 | break; executed: break; Execution Count:24 | 24 |
1188 | case MulticastLoopbackOption: | - |
1189 | ret = d_func()->socketEngine->option(QAbstractSocketEngine::MulticastLoopbackOption); | - |
1190 | break; executed: break; Execution Count:28 | 28 |
1191 | | - |
1192 | case TypeOfServiceOption: | - |
1193 | ret = d_func()->socketEngine->option(QAbstractSocketEngine::TypeOfServiceOption); | - |
1194 | break; | 0 |
1195 | } | - |
1196 | if (ret == -1) evaluated: ret == -1 yes Evaluation Count:26 | yes Evaluation Count:26 |
| 26 |
1197 | return QVariant(); executed: return QVariant(); Execution Count:26 | 26 |
1198 | else | - |
1199 | return QVariant(ret); executed: return QVariant(ret); Execution Count:26 | 26 |
1200 | } | - |
1201 | | - |
1202 | | - |
1203 | | - |
1204 | | - |
1205 | | - |
1206 | | - |
1207 | static int qt_timeout_value(int msecs, int elapsed) | - |
1208 | { | - |
1209 | if (msecs == -1) evaluated: msecs == -1 yes Evaluation Count:11192 | yes Evaluation Count:7688 |
| 7688-11192 |
1210 | return -1; executed: return -1; Execution Count:11192 | 11192 |
1211 | | - |
1212 | int timeout = msecs - elapsed; | - |
1213 | return timeout < 0 ? 0 : timeout; executed: return timeout < 0 ? 0 : timeout; Execution Count:7688 | 7688 |
1214 | } | - |
1215 | bool QAbstractSocket::waitForConnected(int msecs) | - |
1216 | { | - |
1217 | QAbstractSocketPrivate * const d = d_func(); | - |
1218 | | - |
1219 | | - |
1220 | | - |
1221 | | - |
1222 | if (state() == ConnectedState) { evaluated: state() == ConnectedState yes Evaluation Count:6 | yes Evaluation Count:422 |
| 6-422 |
1223 | | - |
1224 | | - |
1225 | | - |
1226 | return true; executed: return true; Execution Count:6 | 6 |
1227 | } | - |
1228 | | - |
1229 | bool wasPendingClose = d->pendingClose; | - |
1230 | d->pendingClose = false; | - |
1231 | QElapsedTimer stopWatch; | - |
1232 | stopWatch.start(); | - |
1233 | | - |
1234 | if (d->state == HostLookupState) { evaluated: d->state == HostLookupState yes Evaluation Count:2 | yes Evaluation Count:420 |
| 2-420 |
1235 | | - |
1236 | | - |
1237 | | - |
1238 | QHostInfo::abortHostLookup(d->hostLookupId); | - |
1239 | d->hostLookupId = -1; | - |
1240 | | - |
1241 | QSharedPointer<QNetworkSession> networkSession; | - |
1242 | QVariant v(property("_q_networksession")); | - |
1243 | if (v.isValid()) { partially evaluated: v.isValid() no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
1244 | networkSession = qvariant_cast< QSharedPointer<QNetworkSession> >(v); | - |
1245 | d->_q_startConnecting(QHostInfoPrivate::fromName(d->hostName, networkSession)); | - |
1246 | } else | 0 |
1247 | | - |
1248 | { | - |
1249 | QHostAddress temp; | - |
1250 | if (temp.setAddress(d->hostName)) { partially evaluated: temp.setAddress(d->hostName) no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
1251 | QHostInfo info; | - |
1252 | info.setAddresses(QList<QHostAddress>() << temp); | - |
1253 | d->_q_startConnecting(info); | - |
1254 | } else { | 0 |
1255 | d->_q_startConnecting(QHostInfo::fromName(d->hostName)); | - |
1256 | } executed: } Execution Count:2 | 2 |
1257 | } | - |
1258 | } | - |
1259 | if (state() == UnconnectedState) evaluated: state() == UnconnectedState yes Evaluation Count:3 | yes Evaluation Count:419 |
| 3-419 |
1260 | return false; executed: return false; Execution Count:3 | 3 |
1261 | | - |
1262 | bool timedOut = true; | - |
1263 | | - |
1264 | | - |
1265 | | - |
1266 | while (state() == ConnectingState && (msecs == -1 || stopWatch.elapsed() < msecs)) { evaluated: state() == ConnectingState yes Evaluation Count:422 | yes Evaluation Count:419 |
partially evaluated: msecs == -1 no Evaluation Count:0 | yes Evaluation Count:422 |
partially evaluated: stopWatch.elapsed() < msecs yes Evaluation Count:422 | no Evaluation Count:0 |
| 0-422 |
1267 | int timeout = qt_timeout_value(msecs, stopWatch.elapsed()); | - |
1268 | if (msecs != -1 && timeout > 30000) partially evaluated: msecs != -1 yes Evaluation Count:422 | no Evaluation Count:0 |
partially evaluated: timeout > 30000 no Evaluation Count:0 | yes Evaluation Count:422 |
| 0-422 |
1269 | timeout = 30000; never executed: timeout = 30000; | 0 |
1270 | | - |
1271 | | - |
1272 | | - |
1273 | | - |
1274 | timedOut = false; | - |
1275 | | - |
1276 | if (d->socketEngine && d->socketEngine->waitForWrite(timeout, &timedOut) && !timedOut) { partially evaluated: d->socketEngine yes Evaluation Count:422 | no Evaluation Count:0 |
partially evaluated: d->socketEngine->waitForWrite(timeout, &timedOut) yes Evaluation Count:422 | no Evaluation Count:0 |
partially evaluated: !timedOut yes Evaluation Count:422 | no Evaluation Count:0 |
| 0-422 |
1277 | d->_q_testConnection(); | - |
1278 | } else { executed: } Execution Count:422 | 422 |
1279 | d->_q_connectToNextAddress(); | - |
1280 | } | 0 |
1281 | } | - |
1282 | | - |
1283 | if ((timedOut && state() != ConnectedState) || state() == ConnectingState) { partially evaluated: timedOut no Evaluation Count:0 | yes Evaluation Count:419 |
never evaluated: state() != ConnectedState partially evaluated: state() == ConnectingState no Evaluation Count:0 | yes Evaluation Count:419 |
| 0-419 |
1284 | d->socketError = SocketTimeoutError; | - |
1285 | d->state = UnconnectedState; | - |
1286 | stateChanged(d->state); | - |
1287 | d->resetSocketLayer(); | - |
1288 | setErrorString(tr("Socket operation timed out")); | - |
1289 | } | 0 |
1290 | | - |
1291 | | - |
1292 | | - |
1293 | | - |
1294 | | - |
1295 | if (state() != ConnectedState) evaluated: state() != ConnectedState yes Evaluation Count:3 | yes Evaluation Count:416 |
| 3-416 |
1296 | return false; executed: return false; Execution Count:3 | 3 |
1297 | if (wasPendingClose) partially evaluated: wasPendingClose no Evaluation Count:0 | yes Evaluation Count:416 |
| 0-416 |
1298 | disconnectFromHost(); never executed: disconnectFromHost(); | 0 |
1299 | return true; executed: return true; Execution Count:416 | 416 |
1300 | } | - |
1301 | bool QAbstractSocket::waitForReadyRead(int msecs) | - |
1302 | { | - |
1303 | QAbstractSocketPrivate * const d = d_func(); | - |
1304 | | - |
1305 | | - |
1306 | | - |
1307 | | - |
1308 | | - |
1309 | if (state() == UnconnectedState) { evaluated: state() == UnconnectedState yes Evaluation Count:24 | yes Evaluation Count:11873 |
| 24-11873 |
1310 | | - |
1311 | | - |
1312 | | - |
1313 | return false; executed: return false; Execution Count:24 | 24 |
1314 | } | - |
1315 | | - |
1316 | QElapsedTimer stopWatch; | - |
1317 | stopWatch.start(); | - |
1318 | | - |
1319 | | - |
1320 | if (state() == HostLookupState || state() == ConnectingState) { evaluated: state() == HostLookupState yes Evaluation Count:1 | yes Evaluation Count:11872 |
evaluated: state() == ConnectingState yes Evaluation Count:81 | yes Evaluation Count:11791 |
| 1-11872 |
1321 | if (!waitForConnected(msecs)) evaluated: !waitForConnected(msecs) yes Evaluation Count:1 | yes Evaluation Count:81 |
| 1-81 |
1322 | return false; executed: return false; Execution Count:1 | 1 |
1323 | } executed: } Execution Count:81 | 81 |
1324 | | - |
1325 | qt_noop(); | - |
1326 | do { | - |
1327 | bool readyToRead = false; | - |
1328 | bool readyToWrite = false; | - |
1329 | if (!d->socketEngine->waitForReadOrWrite(&readyToRead, &readyToWrite, true, !d->writeBuffer.isEmpty(), | 11-11947 |
1330 | qt_timeout_value(msecs, stopWatch.elapsed()))) { evaluated: !d->socketEngine->waitForReadOrWrite(&readyToRead, &readyToWrite, true, !d->writeBuffer.isEmpty(), qt_timeout_value(msecs, stopWatch.elapsed())) yes Evaluation Count:11 | yes Evaluation Count:11947 |
| 11-11947 |
1331 | d->socketError = d->socketEngine->error(); | - |
1332 | setErrorString(d->socketEngine->errorString()); | - |
1333 | | - |
1334 | | - |
1335 | | - |
1336 | | - |
1337 | error(d->socketError); | - |
1338 | if (d->socketError != SocketTimeoutError) partially evaluated: d->socketError != SocketTimeoutError no Evaluation Count:0 | yes Evaluation Count:11 |
| 0-11 |
1339 | close(); | 0 |
1340 | return false; executed: return false; Execution Count:11 | 11 |
1341 | } | - |
1342 | | - |
1343 | if (readyToRead) { evaluated: readyToRead yes Evaluation Count:11861 | yes Evaluation Count:86 |
| 86-11861 |
1344 | if (d->canReadNotification()) evaluated: d->canReadNotification() yes Evaluation Count:11855 | yes Evaluation Count:6 |
| 6-11855 |
1345 | return true; executed: return true; Execution Count:11855 | 11855 |
1346 | } executed: } Execution Count:6 | 6 |
1347 | | - |
1348 | if (readyToWrite) evaluated: readyToWrite yes Evaluation Count:86 | yes Evaluation Count:6 |
| 6-86 |
1349 | d->canWriteNotification(); executed: d->canWriteNotification(); Execution Count:86 | 86 |
1350 | | - |
1351 | if (state() != ConnectedState) evaluated: state() != ConnectedState yes Evaluation Count:6 | yes Evaluation Count:86 |
| 6-86 |
1352 | return false; executed: return false; Execution Count:6 | 6 |
1353 | } while (msecs == -1 || qt_timeout_value(msecs, stopWatch.elapsed()) > 0); executed: } Execution Count:86 partially evaluated: msecs == -1 no Evaluation Count:0 | yes Evaluation Count:86 |
partially evaluated: qt_timeout_value(msecs, stopWatch.elapsed()) > 0 yes Evaluation Count:86 | no Evaluation Count:0 |
| 0-86 |
1354 | return false; never executed: return false; | 0 |
1355 | } | - |
1356 | | - |
1357 | | - |
1358 | | - |
1359 | bool QAbstractSocket::waitForBytesWritten(int msecs) | - |
1360 | { | - |
1361 | QAbstractSocketPrivate * const d = d_func(); | - |
1362 | | - |
1363 | | - |
1364 | | - |
1365 | | - |
1366 | | - |
1367 | if (state() == UnconnectedState) { partially evaluated: state() == UnconnectedState no Evaluation Count:0 | yes Evaluation Count:5126 |
| 0-5126 |
1368 | QMessageLogger("socket/qabstractsocket.cpp", 2144, __PRETTY_FUNCTION__).warning("QAbstractSocket::waitForBytesWritten() is not allowed in UnconnectedState"); | - |
1369 | return false; never executed: return false; | 0 |
1370 | } | - |
1371 | | - |
1372 | if (d->writeBuffer.isEmpty()) evaluated: d->writeBuffer.isEmpty() yes Evaluation Count:99 | yes Evaluation Count:5027 |
| 99-5027 |
1373 | return false; executed: return false; Execution Count:99 | 99 |
1374 | | - |
1375 | QElapsedTimer stopWatch; | - |
1376 | stopWatch.start(); | - |
1377 | | - |
1378 | | - |
1379 | if (state() == HostLookupState || state() == ConnectingState) { partially evaluated: state() == HostLookupState no Evaluation Count:0 | yes Evaluation Count:5027 |
partially evaluated: state() == ConnectingState no Evaluation Count:0 | yes Evaluation Count:5027 |
| 0-5027 |
1380 | if (!waitForConnected(msecs)) never evaluated: !waitForConnected(msecs) | 0 |
1381 | return false; never executed: return false; | 0 |
1382 | } | 0 |
1383 | | - |
1384 | for(;;) { | - |
1385 | bool readyToRead = false; | - |
1386 | bool readyToWrite = false; | - |
1387 | if (!d->socketEngine->waitForReadOrWrite(&readyToRead, &readyToWrite, true, !d->writeBuffer.isEmpty(), | 21-5006 |
1388 | qt_timeout_value(msecs, stopWatch.elapsed()))) { evaluated: !d->socketEngine->waitForReadOrWrite(&readyToRead, &readyToWrite, true, !d->writeBuffer.isEmpty(), qt_timeout_value(msecs, stopWatch.elapsed())) yes Evaluation Count:21 | yes Evaluation Count:5006 |
| 21-5006 |
1389 | d->socketError = d->socketEngine->error(); | - |
1390 | setErrorString(d->socketEngine->errorString()); | - |
1391 | | - |
1392 | | - |
1393 | | - |
1394 | | - |
1395 | error(d->socketError); | - |
1396 | if (d->socketError != SocketTimeoutError) partially evaluated: d->socketError != SocketTimeoutError no Evaluation Count:0 | yes Evaluation Count:21 |
| 0-21 |
1397 | close(); | 0 |
1398 | return false; executed: return false; Execution Count:21 | 21 |
1399 | } | - |
1400 | | - |
1401 | if (readyToRead) { partially evaluated: readyToRead no Evaluation Count:0 | yes Evaluation Count:5006 |
| 0-5006 |
1402 | | - |
1403 | | - |
1404 | | - |
1405 | if(!d->canReadNotification()) never evaluated: !d->canReadNotification() | 0 |
1406 | return false; never executed: return false; | 0 |
1407 | } | 0 |
1408 | | - |
1409 | | - |
1410 | if (readyToWrite) { partially evaluated: readyToWrite yes Evaluation Count:5006 | no Evaluation Count:0 |
| 0-5006 |
1411 | if (d->canWriteNotification()) { partially evaluated: d->canWriteNotification() yes Evaluation Count:5006 | no Evaluation Count:0 |
| 0-5006 |
1412 | | - |
1413 | | - |
1414 | | - |
1415 | return true; executed: return true; Execution Count:5006 | 5006 |
1416 | } | - |
1417 | } | 0 |
1418 | | - |
1419 | if (state() != ConnectedState) never evaluated: state() != ConnectedState | 0 |
1420 | return false; never executed: return false; | 0 |
1421 | } | 0 |
1422 | return false; never executed: return false; | 0 |
1423 | } | - |
1424 | bool QAbstractSocket::waitForDisconnected(int msecs) | - |
1425 | { | - |
1426 | QAbstractSocketPrivate * const d = d_func(); | - |
1427 | | - |
1428 | | - |
1429 | if (state() == UnconnectedState) { partially evaluated: state() == UnconnectedState no Evaluation Count:0 | yes Evaluation Count:71 |
| 0-71 |
1430 | QMessageLogger("socket/qabstractsocket.cpp", 2223, __PRETTY_FUNCTION__).warning("QAbstractSocket::waitForDisconnected() is not allowed in UnconnectedState"); | - |
1431 | return false; never executed: return false; | 0 |
1432 | } | - |
1433 | | - |
1434 | QElapsedTimer stopWatch; | - |
1435 | stopWatch.start(); | - |
1436 | | - |
1437 | | - |
1438 | if (state() == HostLookupState || state() == ConnectingState) { partially evaluated: state() == HostLookupState no Evaluation Count:0 | yes Evaluation Count:71 |
evaluated: state() == ConnectingState yes Evaluation Count:28 | yes Evaluation Count:43 |
| 0-71 |
1439 | if (!waitForConnected(msecs)) partially evaluated: !waitForConnected(msecs) no Evaluation Count:0 | yes Evaluation Count:28 |
| 0-28 |
1440 | return false; never executed: return false; | 0 |
1441 | if (state() == UnconnectedState) partially evaluated: state() == UnconnectedState no Evaluation Count:0 | yes Evaluation Count:28 |
| 0-28 |
1442 | return true; never executed: return true; | 0 |
1443 | } executed: } Execution Count:28 | 28 |
1444 | | - |
1445 | for(;;) { | - |
1446 | bool readyToRead = false; | - |
1447 | bool readyToWrite = false; | - |
1448 | if (!d->socketEngine->waitForReadOrWrite(&readyToRead, &readyToWrite, state() == ConnectedState, | 0-1388 |
1449 | !d->writeBuffer.isEmpty(), | 0-1388 |
1450 | qt_timeout_value(msecs, stopWatch.elapsed()))) { partially evaluated: !d->socketEngine->waitForReadOrWrite(&readyToRead, &readyToWrite, state() == ConnectedState, !d->writeBuffer.isEmpty(), qt_timeout_value(msecs, stopWatch.elapsed())) no Evaluation Count:0 | yes Evaluation Count:1388 |
| 0-1388 |
1451 | d->socketError = d->socketEngine->error(); | - |
1452 | setErrorString(d->socketEngine->errorString()); | - |
1453 | | - |
1454 | | - |
1455 | | - |
1456 | | - |
1457 | error(d->socketError); | - |
1458 | if (d->socketError != SocketTimeoutError) never evaluated: d->socketError != SocketTimeoutError | 0 |
1459 | close(); | 0 |
1460 | return false; never executed: return false; | 0 |
1461 | } | - |
1462 | | - |
1463 | if (readyToRead) evaluated: readyToRead yes Evaluation Count:1360 | yes Evaluation Count:28 |
| 28-1360 |
1464 | d->canReadNotification(); executed: d->canReadNotification(); Execution Count:1360 | 1360 |
1465 | if (readyToWrite) evaluated: readyToWrite yes Evaluation Count:28 | yes Evaluation Count:1360 |
| 28-1360 |
1466 | d->canWriteNotification(); executed: d->canWriteNotification(); Execution Count:28 | 28 |
1467 | | - |
1468 | if (state() == UnconnectedState) evaluated: state() == UnconnectedState yes Evaluation Count:71 | yes Evaluation Count:1317 |
| 71-1317 |
1469 | return true; executed: return true; Execution Count:71 | 71 |
1470 | } executed: } Execution Count:1317 | 1317 |
1471 | return false; never executed: return false; | 0 |
1472 | } | - |
1473 | void QAbstractSocket::abort() | - |
1474 | { | - |
1475 | QAbstractSocketPrivate * const d = d_func(); | - |
1476 | | - |
1477 | | - |
1478 | | - |
1479 | if (d->state == UnconnectedState) evaluated: d->state == UnconnectedState yes Evaluation Count:1 | yes Evaluation Count:1659 |
| 1-1659 |
1480 | return; executed: return; Execution Count:1 | 1 |
1481 | | - |
1482 | if (QSslSocket *socket = qobject_cast<QSslSocket *>(this)) { partially evaluated: QSslSocket *socket = qobject_cast<QSslSocket *>(this) no Evaluation Count:0 | yes Evaluation Count:1659 |
| 0-1659 |
1483 | socket->abort(); | - |
1484 | return; | 0 |
1485 | } | - |
1486 | | - |
1487 | if (d->connectTimer) { evaluated: d->connectTimer yes Evaluation Count:1107 | yes Evaluation Count:552 |
| 552-1107 |
1488 | d->connectTimer->stop(); | - |
1489 | delete d->connectTimer; | - |
1490 | d->connectTimer = 0; | - |
1491 | } executed: } Execution Count:1107 | 1107 |
1492 | | - |
1493 | d->writeBuffer.clear(); | - |
1494 | d->abortCalled = true; | - |
1495 | close(); | - |
1496 | } executed: } Execution Count:1659 | 1659 |
1497 | | - |
1498 | | - |
1499 | | - |
1500 | bool QAbstractSocket::isSequential() const | - |
1501 | { | - |
1502 | return true; executed: return true; Execution Count:1985 | 1985 |
1503 | } | - |
1504 | bool QAbstractSocket::atEnd() const | - |
1505 | { | - |
1506 | return QIODevice::atEnd() && (!isOpen() || d_func()->buffer.isEmpty()); executed: return QIODevice::atEnd() && (!isOpen() || d_func()->buffer.isEmpty()); Execution Count:278 | 278 |
1507 | } | - |
1508 | bool QAbstractSocket::flush() | - |
1509 | { | - |
1510 | QAbstractSocketPrivate * const d = d_func(); | - |
1511 | | - |
1512 | | - |
1513 | | - |
1514 | if (QSslSocket *socket = qobject_cast<QSslSocket *>(this)) partially evaluated: QSslSocket *socket = qobject_cast<QSslSocket *>(this) no Evaluation Count:0 | yes Evaluation Count:12189 |
| 0-12189 |
1515 | return socket->flush(); never executed: return socket->flush(); | 0 |
1516 | | - |
1517 | do { if (!d->socketEngine) { return false; } } while (0); executed: return false; Execution Count:7 executed: } Execution Count:12182 evaluated: !d->socketEngine yes Evaluation Count:7 | yes Evaluation Count:12182 |
partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:12182 |
| 0-12182 |
1518 | return d->flush(); executed: return d->flush(); Execution Count:12182 | 12182 |
1519 | } | - |
1520 | | - |
1521 | | - |
1522 | | - |
1523 | qint64 QAbstractSocket::readData(char *data, qint64 maxSize) | - |
1524 | { | - |
1525 | QAbstractSocketPrivate * const d = d_func(); | - |
1526 | | - |
1527 | | - |
1528 | if (d->socketEngine && !d->socketEngine->isReadNotificationEnabled() && d->socketEngine->isValid()) evaluated: d->socketEngine yes Evaluation Count:308803 | yes Evaluation Count:5627 |
evaluated: !d->socketEngine->isReadNotificationEnabled() yes Evaluation Count:6055 | yes Evaluation Count:302748 |
partially evaluated: d->socketEngine->isValid() yes Evaluation Count:6055 | no Evaluation Count:0 |
| 0-308803 |
1529 | d->socketEngine->setReadNotificationEnabled(true); executed: d->socketEngine->setReadNotificationEnabled(true); Execution Count:6055 | 6055 |
1530 | | - |
1531 | if (!maxSize) evaluated: !maxSize yes Evaluation Count:154003 | yes Evaluation Count:160427 |
| 154003-160427 |
1532 | return 0; executed: return 0; Execution Count:154003 | 154003 |
1533 | | - |
1534 | | - |
1535 | if (d->isBuffered && d->buffer.isEmpty()) evaluated: d->isBuffered yes Evaluation Count:24769 | yes Evaluation Count:135658 |
evaluated: d->buffer.isEmpty() yes Evaluation Count:18954 | yes Evaluation Count:5815 |
| 5815-135658 |
1536 | | - |
1537 | | - |
1538 | return d->state == QAbstractSocket::ConnectedState ? qint64(0) : qint64(-1); executed: return d->state == QAbstractSocket::ConnectedState ? qint64(0) : qint64(-1); Execution Count:18954 | 18954 |
1539 | | - |
1540 | if (!d->socketEngine) evaluated: !d->socketEngine yes Evaluation Count:2719 | yes Evaluation Count:138754 |
| 2719-138754 |
1541 | return -1; executed: return -1; Execution Count:2719 | 2719 |
1542 | if (!d->socketEngine->isValid()) partially evaluated: !d->socketEngine->isValid() no Evaluation Count:0 | yes Evaluation Count:138754 |
| 0-138754 |
1543 | return -1; never executed: return -1; | 0 |
1544 | if (d->state != QAbstractSocket::ConnectedState) partially evaluated: d->state != QAbstractSocket::ConnectedState no Evaluation Count:0 | yes Evaluation Count:138754 |
| 0-138754 |
1545 | return -1; never executed: return -1; | 0 |
1546 | qint64 readBytes = d->socketEngine->read(data, maxSize); | - |
1547 | if (readBytes == -2) { evaluated: readBytes == -2 yes Evaluation Count:5263 | yes Evaluation Count:133491 |
| 5263-133491 |
1548 | | - |
1549 | return 0; executed: return 0; Execution Count:5263 | 5263 |
1550 | } else if (readBytes < 0) { evaluated: readBytes < 0 yes Evaluation Count:128 | yes Evaluation Count:133363 |
| 128-133363 |
1551 | d->socketError = d->socketEngine->error(); | - |
1552 | setErrorString(d->socketEngine->errorString()); | - |
1553 | d->resetSocketLayer(); | - |
1554 | d->state = QAbstractSocket::UnconnectedState; | - |
1555 | } else if (!d->socketEngine->isReadNotificationEnabled()) { executed: } Execution Count:128 partially evaluated: !d->socketEngine->isReadNotificationEnabled() no Evaluation Count:0 | yes Evaluation Count:133363 |
| 0-133363 |
1556 | | - |
1557 | d->socketEngine->setReadNotificationEnabled(true); | - |
1558 | } | 0 |
1559 | | - |
1560 | | - |
1561 | | - |
1562 | | - |
1563 | | - |
1564 | | - |
1565 | return readBytes; executed: return readBytes; Execution Count:133491 | 133491 |
1566 | | - |
1567 | } | - |
1568 | | - |
1569 | | - |
1570 | | - |
1571 | qint64 QAbstractSocket::readLineData(char *data, qint64 maxlen) | - |
1572 | { | - |
1573 | return QIODevice::readLineData(data, maxlen); executed: return QIODevice::readLineData(data, maxlen); Execution Count:4 | 4 |
1574 | } | - |
1575 | | - |
1576 | | - |
1577 | | - |
1578 | qint64 QAbstractSocket::writeData(const char *data, qint64 size) | - |
1579 | { | - |
1580 | QAbstractSocketPrivate * const d = d_func(); | - |
1581 | if (d->state == QAbstractSocket::UnconnectedState) { evaluated: d->state == QAbstractSocket::UnconnectedState yes Evaluation Count:6 | yes Evaluation Count:1297023 |
| 6-1297023 |
1582 | d->socketError = QAbstractSocket::UnknownSocketError; | - |
1583 | setErrorString(tr("Socket is not connected")); | - |
1584 | return -1; executed: return -1; Execution Count:6 | 6 |
1585 | } | - |
1586 | | - |
1587 | if (!d->isBuffered && d->socketType == TcpSocket && d->writeBuffer.isEmpty()) { evaluated: !d->isBuffered yes Evaluation Count:1273904 | yes Evaluation Count:23119 |
evaluated: d->socketType == TcpSocket yes Evaluation Count:1884 | yes Evaluation Count:1272020 |
evaluated: d->writeBuffer.isEmpty() yes Evaluation Count:784 | yes Evaluation Count:1100 |
| 784-1273904 |
1588 | | - |
1589 | qint64 written = d->socketEngine->write(data, size); | - |
1590 | if (written < 0) { partially evaluated: written < 0 no Evaluation Count:0 | yes Evaluation Count:784 |
| 0-784 |
1591 | d->socketError = d->socketEngine->error(); | - |
1592 | setErrorString(d->socketEngine->errorString()); | - |
1593 | return written; never executed: return written; | 0 |
1594 | } else if (written < size) { evaluated: written < size yes Evaluation Count:45 | yes Evaluation Count:739 |
| 45-739 |
1595 | | - |
1596 | char *ptr = d->writeBuffer.reserve(size - written); | - |
1597 | memcpy(ptr, data + written, size - written); | - |
1598 | if (d->socketEngine) partially evaluated: d->socketEngine yes Evaluation Count:45 | no Evaluation Count:0 |
| 0-45 |
1599 | d->socketEngine->setWriteNotificationEnabled(true); executed: d->socketEngine->setWriteNotificationEnabled(true); Execution Count:45 | 45 |
1600 | } executed: } Execution Count:45 | 45 |
1601 | return size; executed: return size; Execution Count:784 | 784 |
1602 | } else if (!d->isBuffered && d->socketType != TcpSocket) { evaluated: !d->isBuffered yes Evaluation Count:1273120 | yes Evaluation Count:23119 |
evaluated: d->socketType != TcpSocket yes Evaluation Count:1272020 | yes Evaluation Count:1100 |
| 1100-1273120 |
1603 | | - |
1604 | qint64 written = d->socketEngine->write(data, size); | - |
1605 | if (written < 0) { partially evaluated: written < 0 no Evaluation Count:0 | yes Evaluation Count:1272020 |
| 0-1272020 |
1606 | d->socketError = d->socketEngine->error(); | - |
1607 | setErrorString(d->socketEngine->errorString()); | - |
1608 | } else if (!d->writeBuffer.isEmpty()) { partially evaluated: !d->writeBuffer.isEmpty() no Evaluation Count:0 | yes Evaluation Count:1272020 |
| 0-1272020 |
1609 | d->socketEngine->setWriteNotificationEnabled(true); | - |
1610 | } | 0 |
1611 | | - |
1612 | | - |
1613 | | - |
1614 | | - |
1615 | | - |
1616 | | - |
1617 | if (written >= 0) partially evaluated: written >= 0 yes Evaluation Count:1272020 | no Evaluation Count:0 |
| 0-1272020 |
1618 | bytesWritten(written); executed: bytesWritten(written); Execution Count:1272020 | 1272020 |
1619 | return written; executed: return written; Execution Count:1272020 | 1272020 |
1620 | } | - |
1621 | | - |
1622 | | - |
1623 | | - |
1624 | | - |
1625 | | - |
1626 | | - |
1627 | | - |
1628 | char *ptr = d->writeBuffer.reserve(size); | - |
1629 | if (size == 1) evaluated: size == 1 yes Evaluation Count:11226 | yes Evaluation Count:12993 |
| 11226-12993 |
1630 | *ptr = *data; executed: *ptr = *data; Execution Count:11226 | 11226 |
1631 | else | - |
1632 | memcpy(ptr, data, size); executed: memcpy(ptr, data, size); Execution Count:12993 | 12993 |
1633 | | - |
1634 | qint64 written = size; | - |
1635 | | - |
1636 | if (d->socketEngine && !d->writeBuffer.isEmpty()) partially evaluated: d->socketEngine yes Evaluation Count:24219 | no Evaluation Count:0 |
evaluated: !d->writeBuffer.isEmpty() yes Evaluation Count:24206 | yes Evaluation Count:13 |
| 0-24219 |
1637 | d->socketEngine->setWriteNotificationEnabled(true); executed: d->socketEngine->setWriteNotificationEnabled(true); Execution Count:24206 | 24206 |
1638 | | - |
1639 | | - |
1640 | | - |
1641 | | - |
1642 | | - |
1643 | | - |
1644 | return written; executed: return written; Execution Count:24219 | 24219 |
1645 | } | - |
1646 | void QAbstractSocket::setLocalPort(quint16 port) | - |
1647 | { | - |
1648 | QAbstractSocketPrivate * const d = d_func(); | - |
1649 | d->localPort = port; | - |
1650 | } executed: } Execution Count:229 | 229 |
1651 | void QAbstractSocket::setLocalAddress(const QHostAddress &address) | - |
1652 | { | - |
1653 | QAbstractSocketPrivate * const d = d_func(); | - |
1654 | d->localAddress = address; | - |
1655 | } executed: } Execution Count:227 | 227 |
1656 | void QAbstractSocket::setPeerPort(quint16 port) | - |
1657 | { | - |
1658 | QAbstractSocketPrivate * const d = d_func(); | - |
1659 | d->peerPort = port; | - |
1660 | } executed: } Execution Count:229 | 229 |
1661 | void QAbstractSocket::setPeerAddress(const QHostAddress &address) | - |
1662 | { | - |
1663 | QAbstractSocketPrivate * const d = d_func(); | - |
1664 | d->peerAddress = address; | - |
1665 | } executed: } Execution Count:227 | 227 |
1666 | void QAbstractSocket::setPeerName(const QString &name) | - |
1667 | { | - |
1668 | QAbstractSocketPrivate * const d = d_func(); | - |
1669 | d->peerName = name; | - |
1670 | } executed: } Execution Count:227 | 227 |
1671 | void QAbstractSocket::close() | - |
1672 | { | - |
1673 | QAbstractSocketPrivate * const d = d_func(); | - |
1674 | | - |
1675 | | - |
1676 | | - |
1677 | QIODevice::close(); | - |
1678 | if (d->state != UnconnectedState) { evaluated: d->state != UnconnectedState yes Evaluation Count:2637 | yes Evaluation Count:563 |
| 563-2637 |
1679 | d->closeCalled = true; | - |
1680 | disconnectFromHost(); | - |
1681 | } executed: } Execution Count:2637 | 2637 |
1682 | | - |
1683 | d->localPort = 0; | - |
1684 | d->peerPort = 0; | - |
1685 | d->localAddress.clear(); | - |
1686 | d->peerAddress.clear(); | - |
1687 | d->peerName.clear(); | - |
1688 | d->cachedSocketDescriptor = -1; | - |
1689 | } executed: } Execution Count:3200 | 3200 |
1690 | void QAbstractSocket::disconnectFromHost() | - |
1691 | { | - |
1692 | QAbstractSocketPrivate * const d = d_func(); | - |
1693 | | - |
1694 | | - |
1695 | | - |
1696 | | - |
1697 | if (d->state == UnconnectedState) { evaluated: d->state == UnconnectedState yes Evaluation Count:6 | yes Evaluation Count:3168 |
| 6-3168 |
1698 | | - |
1699 | | - |
1700 | | - |
1701 | return; executed: return; Execution Count:6 | 6 |
1702 | } | - |
1703 | | - |
1704 | if (!d->abortCalled && (d->state == ConnectingState || d->state == HostLookupState)) { evaluated: !d->abortCalled yes Evaluation Count:1509 | yes Evaluation Count:1659 |
evaluated: d->state == ConnectingState yes Evaluation Count:3 | yes Evaluation Count:1506 |
partially evaluated: d->state == HostLookupState no Evaluation Count:0 | yes Evaluation Count:1506 |
| 0-1659 |
1705 | | - |
1706 | | - |
1707 | | - |
1708 | d->pendingClose = true; | - |
1709 | return; executed: return; Execution Count:3 | 3 |
1710 | } | - |
1711 | | - |
1712 | | - |
1713 | if (d->socketEngine) evaluated: d->socketEngine yes Evaluation Count:2842 | yes Evaluation Count:323 |
| 323-2842 |
1714 | d->socketEngine->setReadNotificationEnabled(false); executed: d->socketEngine->setReadNotificationEnabled(false); Execution Count:2842 | 2842 |
1715 | | - |
1716 | if (d->abortCalled) { evaluated: d->abortCalled yes Evaluation Count:1659 | yes Evaluation Count:1506 |
| 1506-1659 |
1717 | | - |
1718 | | - |
1719 | | - |
1720 | if (d->state == HostLookupState) { evaluated: d->state == HostLookupState yes Evaluation Count:118 | yes Evaluation Count:1541 |
| 118-1541 |
1721 | QHostInfo::abortHostLookup(d->hostLookupId); | - |
1722 | d->hostLookupId = -1; | - |
1723 | } executed: } Execution Count:118 | 118 |
1724 | } else { executed: } Execution Count:1659 | 1659 |
1725 | | - |
1726 | if (d->state != ClosingState) { evaluated: d->state != ClosingState yes Evaluation Count:1362 | yes Evaluation Count:144 |
| 144-1362 |
1727 | d->state = ClosingState; | - |
1728 | | - |
1729 | | - |
1730 | | - |
1731 | stateChanged(d->state); | - |
1732 | } else { executed: } Execution Count:1362 | 1362 |
1733 | | - |
1734 | | - |
1735 | | - |
1736 | } executed: } Execution Count:144 | 144 |
1737 | | - |
1738 | | - |
1739 | if (d->socketEngine && d->socketEngine->isValid() && (d->writeBuffer.size() > 0 evaluated: d->socketEngine yes Evaluation Count:1301 | yes Evaluation Count:205 |
partially evaluated: d->socketEngine->isValid() yes Evaluation Count:1301 | no Evaluation Count:0 |
evaluated: d->writeBuffer.size() > 0 yes Evaluation Count:147 | yes Evaluation Count:1154 |
| 0-1301 |
1740 | || d->socketEngine->bytesToWrite() > 0)) { partially evaluated: d->socketEngine->bytesToWrite() > 0 no Evaluation Count:0 | yes Evaluation Count:1154 |
| 0-1154 |
1741 | | - |
1742 | | - |
1743 | | - |
1744 | | - |
1745 | | - |
1746 | if (d->writeBuffer.size() == 0 && d->socketEngine->bytesToWrite() > 0) { partially evaluated: d->writeBuffer.size() == 0 no Evaluation Count:0 | yes Evaluation Count:147 |
never evaluated: d->socketEngine->bytesToWrite() > 0 | 0-147 |
1747 | if (!d->disconnectTimer) { never evaluated: !d->disconnectTimer | 0 |
1748 | d->disconnectTimer = new QTimer(this); | - |
1749 | connect(d->disconnectTimer, "2""timeout()", this, | - |
1750 | "1""_q_forceDisconnect()", Qt::DirectConnection); | - |
1751 | } | 0 |
1752 | if (!d->disconnectTimer->isActive()) never evaluated: !d->disconnectTimer->isActive() | 0 |
1753 | d->disconnectTimer->start(2000); never executed: d->disconnectTimer->start(2000); | 0 |
1754 | } | 0 |
1755 | d->socketEngine->setWriteNotificationEnabled(true); | - |
1756 | | - |
1757 | | - |
1758 | | - |
1759 | | - |
1760 | return; executed: return; Execution Count:147 | 147 |
1761 | } else { | - |
1762 | | - |
1763 | | - |
1764 | | - |
1765 | } executed: } Execution Count:1359 | 1359 |
1766 | } | - |
1767 | | - |
1768 | SocketState previousState = d->state; | - |
1769 | d->resetSocketLayer(); | - |
1770 | d->state = UnconnectedState; | - |
1771 | stateChanged(d->state); | - |
1772 | readChannelFinished(); | - |
1773 | | - |
1774 | | - |
1775 | if (previousState == ConnectedState || previousState == ClosingState) evaluated: previousState == ConnectedState yes Evaluation Count:422 | yes Evaluation Count:2596 |
evaluated: previousState == ClosingState yes Evaluation Count:1362 | yes Evaluation Count:1234 |
| 422-2596 |
1776 | disconnected(); executed: disconnected(); Execution Count:1784 | 1784 |
1777 | | - |
1778 | d->localPort = 0; | - |
1779 | d->peerPort = 0; | - |
1780 | d->localAddress.clear(); | - |
1781 | d->peerAddress.clear(); | - |
1782 | | - |
1783 | | - |
1784 | | - |
1785 | | - |
1786 | | - |
1787 | if (d->closeCalled) { evaluated: d->closeCalled yes Evaluation Count:2629 | yes Evaluation Count:389 |
| 389-2629 |
1788 | | - |
1789 | | - |
1790 | | - |
1791 | d->buffer.clear(); | - |
1792 | d->writeBuffer.clear(); | - |
1793 | QIODevice::close(); | - |
1794 | } executed: } Execution Count:2629 | 2629 |
1795 | } executed: } Execution Count:3018 | 3018 |
1796 | qint64 QAbstractSocket::readBufferSize() const | - |
1797 | { | - |
1798 | return d_func()->readBufferMaxSize; executed: return d_func()->readBufferMaxSize; Execution Count:19 | 19 |
1799 | } | - |
1800 | void QAbstractSocket::setReadBufferSize(qint64 size) | - |
1801 | { | - |
1802 | QAbstractSocketPrivate * const d = d_func(); | - |
1803 | | - |
1804 | if (d->readBufferMaxSize == size) evaluated: d->readBufferMaxSize == size yes Evaluation Count:292 | yes Evaluation Count:604 |
| 292-604 |
1805 | return; executed: return; Execution Count:292 | 292 |
1806 | d->readBufferMaxSize = size; | - |
1807 | if (!d->readSocketNotifierCalled && d->socketEngine) { partially evaluated: !d->readSocketNotifierCalled yes Evaluation Count:604 | no Evaluation Count:0 |
evaluated: d->socketEngine yes Evaluation Count:535 | yes Evaluation Count:69 |
| 0-604 |
1808 | | - |
1809 | | - |
1810 | | - |
1811 | if ((size == 0 || d->buffer.size() < size) && d->state == QAbstractSocket::ConnectedState) evaluated: size == 0 yes Evaluation Count:2 | yes Evaluation Count:533 |
partially evaluated: d->buffer.size() < size yes Evaluation Count:533 | no Evaluation Count:0 |
evaluated: d->state == QAbstractSocket::ConnectedState yes Evaluation Count:4 | yes Evaluation Count:531 |
| 0-533 |
1812 | d->socketEngine->setReadNotificationEnabled(true); executed: d->socketEngine->setReadNotificationEnabled(true); Execution Count:4 | 4 |
1813 | } executed: } Execution Count:535 | 535 |
1814 | } executed: } Execution Count:604 | 604 |
1815 | | - |
1816 | | - |
1817 | | - |
1818 | | - |
1819 | | - |
1820 | | - |
1821 | QAbstractSocket::SocketState QAbstractSocket::state() const | - |
1822 | { | - |
1823 | return d_func()->state; executed: return d_func()->state; Execution Count:431140 | 431140 |
1824 | } | - |
1825 | | - |
1826 | | - |
1827 | | - |
1828 | | - |
1829 | | - |
1830 | | - |
1831 | void QAbstractSocket::setSocketState(SocketState state) | - |
1832 | { | - |
1833 | d_func()->state = state; | - |
1834 | } executed: } Execution Count:830 | 830 |
1835 | | - |
1836 | | - |
1837 | | - |
1838 | | - |
1839 | | - |
1840 | | - |
1841 | QAbstractSocket::SocketType QAbstractSocket::socketType() const | - |
1842 | { | - |
1843 | return d_func()->socketType; executed: return d_func()->socketType; Execution Count:4930 | 4930 |
1844 | } | - |
1845 | | - |
1846 | | - |
1847 | | - |
1848 | | - |
1849 | | - |
1850 | | - |
1851 | QAbstractSocket::SocketError QAbstractSocket::error() const | - |
1852 | { | - |
1853 | return d_func()->socketError; executed: return d_func()->socketError; Execution Count:145 | 145 |
1854 | } | - |
1855 | | - |
1856 | | - |
1857 | | - |
1858 | | - |
1859 | | - |
1860 | | - |
1861 | void QAbstractSocket::setSocketError(SocketError socketError) | - |
1862 | { | - |
1863 | d_func()->socketError = socketError; | - |
1864 | } executed: } Execution Count:176 | 176 |
1865 | void QAbstractSocket::setProxy(const QNetworkProxy &networkProxy) | - |
1866 | { | - |
1867 | QAbstractSocketPrivate * const d = d_func(); | - |
1868 | d->proxy = networkProxy; | - |
1869 | } executed: } Execution Count:976 | 976 |
1870 | QNetworkProxy QAbstractSocket::proxy() const | - |
1871 | { | - |
1872 | const QAbstractSocketPrivate * const d = d_func(); | - |
1873 | return d->proxy; executed: return d->proxy; Execution Count:2475 | 2475 |
1874 | } | - |
1875 | | - |
1876 | | - |
1877 | | - |
1878 | __attribute__((visibility("default"))) QDebug operator<<(QDebug debug, QAbstractSocket::SocketError error) | - |
1879 | { | - |
1880 | switch (error) { | - |
1881 | case QAbstractSocket::ConnectionRefusedError: | - |
1882 | debug << "QAbstractSocket::ConnectionRefusedError"; | - |
1883 | break; | 0 |
1884 | case QAbstractSocket::RemoteHostClosedError: | - |
1885 | debug << "QAbstractSocket::RemoteHostClosedError"; | - |
1886 | break; executed: break; Execution Count:23 | 23 |
1887 | case QAbstractSocket::HostNotFoundError: | - |
1888 | debug << "QAbstractSocket::HostNotFoundError"; | - |
1889 | break; | 0 |
1890 | case QAbstractSocket::SocketAccessError: | - |
1891 | debug << "QAbstractSocket::SocketAccessError"; | - |
1892 | break; | 0 |
1893 | case QAbstractSocket::SocketResourceError: | - |
1894 | debug << "QAbstractSocket::SocketResourceError"; | - |
1895 | break; | 0 |
1896 | case QAbstractSocket::SocketTimeoutError: | - |
1897 | debug << "QAbstractSocket::SocketTimeoutError"; | - |
1898 | break; | 0 |
1899 | case QAbstractSocket::DatagramTooLargeError: | - |
1900 | debug << "QAbstractSocket::DatagramTooLargeError"; | - |
1901 | break; | 0 |
1902 | case QAbstractSocket::NetworkError: | - |
1903 | debug << "QAbstractSocket::NetworkError"; | - |
1904 | break; | 0 |
1905 | case QAbstractSocket::AddressInUseError: | - |
1906 | debug << "QAbstractSocket::AddressInUseError"; | - |
1907 | break; | 0 |
1908 | case QAbstractSocket::SocketAddressNotAvailableError: | - |
1909 | debug << "QAbstractSocket::SocketAddressNotAvailableError"; | - |
1910 | break; | 0 |
1911 | case QAbstractSocket::UnsupportedSocketOperationError: | - |
1912 | debug << "QAbstractSocket::UnsupportedSocketOperationError"; | - |
1913 | break; | 0 |
1914 | case QAbstractSocket::UnfinishedSocketOperationError: | - |
1915 | debug << "QAbstractSocket::UnfinishedSocketOperationError"; | - |
1916 | break; | 0 |
1917 | case QAbstractSocket::ProxyAuthenticationRequiredError: | - |
1918 | debug << "QAbstractSocket::ProxyAuthenticationRequiredError"; | - |
1919 | break; | 0 |
1920 | case QAbstractSocket::UnknownSocketError: | - |
1921 | debug << "QAbstractSocket::UnknownSocketError"; | - |
1922 | break; | 0 |
1923 | case QAbstractSocket::ProxyConnectionRefusedError: | - |
1924 | debug << "QAbstractSocket::ProxyConnectionRefusedError"; | - |
1925 | break; | 0 |
1926 | case QAbstractSocket::ProxyConnectionClosedError: | - |
1927 | debug << "QAbstractSocket::ProxyConnectionClosedError"; | - |
1928 | break; | 0 |
1929 | case QAbstractSocket::ProxyConnectionTimeoutError: | - |
1930 | debug << "QAbstractSocket::ProxyConnectionTimeoutError"; | - |
1931 | break; | 0 |
1932 | case QAbstractSocket::ProxyNotFoundError: | - |
1933 | debug << "QAbstractSocket::ProxyNotFoundError"; | - |
1934 | break; | 0 |
1935 | case QAbstractSocket::ProxyProtocolError: | - |
1936 | debug << "QAbstractSocket::ProxyProtocolError"; | - |
1937 | break; | 0 |
1938 | default: | - |
1939 | debug << "QAbstractSocket::SocketError(" << int(error) << ')'; | - |
1940 | break; | 0 |
1941 | } | - |
1942 | return debug; executed: return debug; Execution Count:23 | 23 |
1943 | } | - |
1944 | | - |
1945 | __attribute__((visibility("default"))) QDebug operator<<(QDebug debug, QAbstractSocket::SocketState state) | - |
1946 | { | - |
1947 | switch (state) { | - |
1948 | case QAbstractSocket::UnconnectedState: | - |
1949 | debug << "QAbstractSocket::UnconnectedState"; | - |
1950 | break; | 0 |
1951 | case QAbstractSocket::HostLookupState: | - |
1952 | debug << "QAbstractSocket::HostLookupState"; | - |
1953 | break; | 0 |
1954 | case QAbstractSocket::ConnectingState: | - |
1955 | debug << "QAbstractSocket::ConnectingState"; | - |
1956 | break; | 0 |
1957 | case QAbstractSocket::ConnectedState: | - |
1958 | debug << "QAbstractSocket::ConnectedState"; | - |
1959 | break; | 0 |
1960 | case QAbstractSocket::BoundState: | - |
1961 | debug << "QAbstractSocket::BoundState"; | - |
1962 | break; | 0 |
1963 | case QAbstractSocket::ListeningState: | - |
1964 | debug << "QAbstractSocket::ListeningState"; | - |
1965 | break; | 0 |
1966 | case QAbstractSocket::ClosingState: | - |
1967 | debug << "QAbstractSocket::ClosingState"; | - |
1968 | break; | 0 |
1969 | default: | - |
1970 | debug << "QAbstractSocket::SocketState(" << int(state) << ')'; | - |
1971 | break; | 0 |
1972 | } | - |
1973 | return debug; never executed: return debug; | 0 |
1974 | } | - |
1975 | | - |
1976 | | - |
1977 | | - |
1978 | | - |
1979 | | - |
| | |