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