| Line | Source Code | Coverage |
|---|
| 1 | /**************************************************************************** | - |
| 2 | ** | - |
| 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
| 4 | ** Contact: http://www.qt-project.org/legal | - |
| 5 | ** | - |
| 6 | ** This file is part of the QtNetwork module of the Qt Toolkit. | - |
| 7 | ** | - |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
| 9 | ** Commercial License Usage | - |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
| 11 | ** accordance with the commercial license agreement provided with the | - |
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - |
| 13 | ** a written agreement between you and Digia. For licensing terms and | - |
| 14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
| 15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
| 16 | ** | - |
| 17 | ** GNU Lesser General Public License Usage | - |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
| 19 | ** General Public License version 2.1 as published by the Free Software | - |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
| 21 | ** packaging of this file. Please review the following information to | - |
| 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
| 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
| 24 | ** | - |
| 25 | ** In addition, as a special exception, Digia gives you certain additional | - |
| 26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
| 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
| 28 | ** | - |
| 29 | ** GNU General Public License Usage | - |
| 30 | ** Alternatively, this file may be used under the terms of the GNU | - |
| 31 | ** General Public License version 3.0 as published by the Free Software | - |
| 32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
| 33 | ** packaging of this file. Please review the following information to | - |
| 34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
| 35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
| 36 | ** | - |
| 37 | ** | - |
| 38 | ** $QT_END_LICENSE$ | - |
| 39 | ** | - |
| 40 | ****************************************************************************/ | - |
| 41 | | - |
| 42 | #include "qlocalserver.h" | - |
| 43 | #include "qlocalserver_p.h" | - |
| 44 | #include "qlocalsocket.h" | - |
| 45 | #include "qlocalsocket_p.h" | - |
| 46 | #include "qnet_unix_p.h" | - |
| 47 | #include "qtemporarydir.h" | - |
| 48 | | - |
| 49 | #ifndef QT_NO_LOCALSERVER | - |
| 50 | | - |
| 51 | #include <sys/socket.h> | - |
| 52 | #include <sys/un.h> | - |
| 53 | | - |
| 54 | #include <qdebug.h> | - |
| 55 | #include <qdir.h> | - |
| 56 | #include <qdatetime.h> | - |
| 57 | | - |
| 58 | #ifdef Q_OS_VXWORKS | - |
| 59 | # include <selectLib.h> | - |
| 60 | #endif | - |
| 61 | | - |
| 62 | QT_BEGIN_NAMESPACE | - |
| 63 | | - |
| 64 | void QLocalServerPrivate::init() | - |
| 65 | { | - |
| 66 | } | - |
| 67 | | - |
| 68 | bool QLocalServerPrivate::removeServer(const QString &name) | - |
| 69 | { | - |
| 70 | QString fileName; executed (the execution status of this line is deduced): QString fileName; | - |
| 71 | if (name.startsWith(QLatin1Char('/'))) { partially evaluated: name.startsWith(QLatin1Char('/'))| no Evaluation Count:0 | yes Evaluation Count:37 |
| 0-37 |
| 72 | fileName = name; never executed (the execution status of this line is deduced): fileName = name; | - |
| 73 | } else { | 0 |
| 74 | fileName = QDir::cleanPath(QDir::tempPath()); executed (the execution status of this line is deduced): fileName = QDir::cleanPath(QDir::tempPath()); | - |
| 75 | fileName += QLatin1Char('/') + name; executed (the execution status of this line is deduced): fileName += QLatin1Char('/') + name; | - |
| 76 | } executed: }Execution Count:37 | 37 |
| 77 | if (QFile::exists(fileName)) evaluated: QFile::exists(fileName)| yes Evaluation Count:11 | yes Evaluation Count:26 |
| 11-26 |
| 78 | return QFile::remove(fileName); executed: return QFile::remove(fileName);Execution Count:11 | 11 |
| 79 | else | - |
| 80 | return true; executed: return true;Execution Count:26 | 26 |
| 81 | } | - |
| 82 | | - |
| 83 | bool QLocalServerPrivate::listen(const QString &requestedServerName) | - |
| 84 | { | - |
| 85 | Q_Q(QLocalServer); executed (the execution status of this line is deduced): QLocalServer * const q = q_func(); | - |
| 86 | | - |
| 87 | // determine the full server path | - |
| 88 | if (requestedServerName.startsWith(QLatin1Char('/'))) { evaluated: requestedServerName.startsWith(QLatin1Char('/'))| yes Evaluation Count:1 | yes Evaluation Count:43 |
| 1-43 |
| 89 | fullServerName = requestedServerName; executed (the execution status of this line is deduced): fullServerName = requestedServerName; | - |
| 90 | } else { executed: }Execution Count:1 | 1 |
| 91 | fullServerName = QDir::cleanPath(QDir::tempPath()); executed (the execution status of this line is deduced): fullServerName = QDir::cleanPath(QDir::tempPath()); | - |
| 92 | fullServerName += QLatin1Char('/') + requestedServerName; executed (the execution status of this line is deduced): fullServerName += QLatin1Char('/') + requestedServerName; | - |
| 93 | } executed: }Execution Count:43 | 43 |
| 94 | serverName = requestedServerName; executed (the execution status of this line is deduced): serverName = requestedServerName; | - |
| 95 | | - |
| 96 | QString tempPath; executed (the execution status of this line is deduced): QString tempPath; | - |
| 97 | QScopedPointer<QTemporaryDir> tempDir; executed (the execution status of this line is deduced): QScopedPointer<QTemporaryDir> tempDir; | - |
| 98 | | - |
| 99 | // Check any of the flags | - |
| 100 | if (socketOptions & QLocalServer::WorldAccessOption) { evaluated: socketOptions & QLocalServer::WorldAccessOption| yes Evaluation Count:4 | yes Evaluation Count:40 |
| 4-40 |
| 101 | tempDir.reset(new QTemporaryDir(fullServerName)); executed (the execution status of this line is deduced): tempDir.reset(new QTemporaryDir(fullServerName)); | - |
| 102 | if (!tempDir->isValid()) { partially evaluated: !tempDir->isValid()| no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
| 103 | setError(QLatin1String("QLocalServer::listen")); never executed (the execution status of this line is deduced): setError(QLatin1String("QLocalServer::listen")); | - |
| 104 | return false; never executed: return false; | 0 |
| 105 | } | - |
| 106 | tempPath = tempDir->path(); executed (the execution status of this line is deduced): tempPath = tempDir->path(); | - |
| 107 | tempPath += QLatin1Char('/') + requestedServerName; executed (the execution status of this line is deduced): tempPath += QLatin1Char('/') + requestedServerName; | - |
| 108 | } executed: }Execution Count:4 | 4 |
| 109 | | - |
| 110 | // create the unix socket | - |
| 111 | listenSocket = qt_safe_socket(PF_UNIX, SOCK_STREAM, 0); executed (the execution status of this line is deduced): listenSocket = qt_safe_socket(1, SOCK_STREAM, 0); | - |
| 112 | if (-1 == listenSocket) { partially evaluated: -1 == listenSocket| no Evaluation Count:0 | yes Evaluation Count:44 |
| 0-44 |
| 113 | setError(QLatin1String("QLocalServer::listen")); never executed (the execution status of this line is deduced): setError(QLatin1String("QLocalServer::listen")); | - |
| 114 | closeServer(); never executed (the execution status of this line is deduced): closeServer(); | - |
| 115 | return false; never executed: return false; | 0 |
| 116 | } | - |
| 117 | | - |
| 118 | // Construct the unix address | - |
| 119 | struct ::sockaddr_un addr; executed (the execution status of this line is deduced): struct ::sockaddr_un addr; | - |
| 120 | addr.sun_family = PF_UNIX; executed (the execution status of this line is deduced): addr.sun_family = 1; | - |
| 121 | if (sizeof(addr.sun_path) < (uint)fullServerName.toLatin1().size() + 1) { evaluated: sizeof(addr.sun_path) < (uint)fullServerName.toLatin1().size() + 1| yes Evaluation Count:1 | yes Evaluation Count:43 |
| 1-43 |
| 122 | setError(QLatin1String("QLocalServer::listen")); executed (the execution status of this line is deduced): setError(QLatin1String("QLocalServer::listen")); | - |
| 123 | closeServer(); executed (the execution status of this line is deduced): closeServer(); | - |
| 124 | return false; executed: return false;Execution Count:1 | 1 |
| 125 | } | - |
| 126 | | - |
| 127 | if (socketOptions & QLocalServer::WorldAccessOption) { evaluated: socketOptions & QLocalServer::WorldAccessOption| yes Evaluation Count:4 | yes Evaluation Count:39 |
| 4-39 |
| 128 | if (sizeof(addr.sun_path) < (uint)tempPath.toLatin1().size() + 1) { partially evaluated: sizeof(addr.sun_path) < (uint)tempPath.toLatin1().size() + 1| no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
| 129 | setError(QLatin1String("QLocalServer::listen")); never executed (the execution status of this line is deduced): setError(QLatin1String("QLocalServer::listen")); | - |
| 130 | closeServer(); never executed (the execution status of this line is deduced): closeServer(); | - |
| 131 | return false; never executed: return false; | 0 |
| 132 | } | - |
| 133 | ::memcpy(addr.sun_path, tempPath.toLatin1().data(), executed (the execution status of this line is deduced): ::memcpy(addr.sun_path, tempPath.toLatin1().data(), | - |
| 134 | tempPath.toLatin1().size() + 1); executed (the execution status of this line is deduced): tempPath.toLatin1().size() + 1); | - |
| 135 | | - |
| 136 | if (-1 == ::fchmod(listenSocket, 0)) { partially evaluated: -1 == ::fchmod(listenSocket, 0)| no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
| 137 | setError(QLatin1String("QLocalServer::listen")); never executed (the execution status of this line is deduced): setError(QLatin1String("QLocalServer::listen")); | - |
| 138 | closeServer(); never executed (the execution status of this line is deduced): closeServer(); | - |
| 139 | return false; never executed: return false; | 0 |
| 140 | } | - |
| 141 | | - |
| 142 | } else { executed: }Execution Count:4 | 4 |
| 143 | ::memcpy(addr.sun_path, fullServerName.toLatin1().data(), executed (the execution status of this line is deduced): ::memcpy(addr.sun_path, fullServerName.toLatin1().data(), | - |
| 144 | fullServerName.toLatin1().size() + 1); executed (the execution status of this line is deduced): fullServerName.toLatin1().size() + 1); | - |
| 145 | } executed: }Execution Count:39 | 39 |
| 146 | | - |
| 147 | // bind | - |
| 148 | if(-1 == QT_SOCKET_BIND(listenSocket, (sockaddr *)&addr, sizeof(sockaddr_un))) { evaluated: -1 == ::bind(listenSocket, (sockaddr *)&addr, sizeof(sockaddr_un))| yes Evaluation Count:1 | yes Evaluation Count:42 |
| 1-42 |
| 149 | setError(QLatin1String("QLocalServer::listen")); executed (the execution status of this line is deduced): setError(QLatin1String("QLocalServer::listen")); | - |
| 150 | // if address is in use already, just close the socket, but do not delete the file | - |
| 151 | if(errno == EADDRINUSE) partially evaluated: (*__errno_location ()) == 98| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 152 | QT_CLOSE(listenSocket); executed: qt_safe_close(listenSocket);Execution Count:1 | 1 |
| 153 | // otherwise, close the socket and delete the file | - |
| 154 | else | - |
| 155 | closeServer(); never executed: closeServer(); | 0 |
| 156 | listenSocket = -1; executed (the execution status of this line is deduced): listenSocket = -1; | - |
| 157 | return false; executed: return false;Execution Count:1 | 1 |
| 158 | } | - |
| 159 | | - |
| 160 | // listen for connections | - |
| 161 | if (-1 == qt_safe_listen(listenSocket, 50)) { partially evaluated: -1 == qt_safe_listen(listenSocket, 50)| no Evaluation Count:0 | yes Evaluation Count:42 |
| 0-42 |
| 162 | setError(QLatin1String("QLocalServer::listen")); never executed (the execution status of this line is deduced): setError(QLatin1String("QLocalServer::listen")); | - |
| 163 | closeServer(); never executed (the execution status of this line is deduced): closeServer(); | - |
| 164 | listenSocket = -1; never executed (the execution status of this line is deduced): listenSocket = -1; | - |
| 165 | if (error != QAbstractSocket::AddressInUseError) never evaluated: error != QAbstractSocket::AddressInUseError | 0 |
| 166 | QFile::remove(fullServerName); never executed: QFile::remove(fullServerName); | 0 |
| 167 | return false; never executed: return false; | 0 |
| 168 | } | - |
| 169 | | - |
| 170 | if (socketOptions & QLocalServer::WorldAccessOption) { evaluated: socketOptions & QLocalServer::WorldAccessOption| yes Evaluation Count:4 | yes Evaluation Count:38 |
| 4-38 |
| 171 | mode_t mode = 000; executed (the execution status of this line is deduced): mode_t mode = 000; | - |
| 172 | | - |
| 173 | if (socketOptions & QLocalServer::UserAccessOption) { evaluated: socketOptions & QLocalServer::UserAccessOption| yes Evaluation Count:2 | yes Evaluation Count:2 |
| 2 |
| 174 | mode |= S_IRWXU; executed (the execution status of this line is deduced): mode |= (0400|0200|0100); | - |
| 175 | } executed: }Execution Count:2 | 2 |
| 176 | if (socketOptions & QLocalServer::GroupAccessOption) { evaluated: socketOptions & QLocalServer::GroupAccessOption| yes Evaluation Count:2 | yes Evaluation Count:2 |
| 2 |
| 177 | mode |= S_IRWXG; executed (the execution status of this line is deduced): mode |= ((0400|0200|0100) >> 3); | - |
| 178 | } executed: }Execution Count:2 | 2 |
| 179 | if (socketOptions & QLocalServer::OtherAccessOption) { evaluated: socketOptions & QLocalServer::OtherAccessOption| yes Evaluation Count:2 | yes Evaluation Count:2 |
| 2 |
| 180 | mode |= S_IRWXO; executed (the execution status of this line is deduced): mode |= (((0400|0200|0100) >> 3) >> 3); | - |
| 181 | } executed: }Execution Count:2 | 2 |
| 182 | | - |
| 183 | if (mode) { partially evaluated: mode| yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
| 184 | if (-1 == ::chmod(tempPath.toLatin1(), mode)) { partially evaluated: -1 == ::chmod(tempPath.toLatin1(), mode)| no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
| 185 | setError(QLatin1String("QLocalServer::listen")); never executed (the execution status of this line is deduced): setError(QLatin1String("QLocalServer::listen")); | - |
| 186 | closeServer(); never executed (the execution status of this line is deduced): closeServer(); | - |
| 187 | return false; never executed: return false; | 0 |
| 188 | } | - |
| 189 | } executed: }Execution Count:4 | 4 |
| 190 | if (-1 == ::rename(tempPath.toLatin1(), fullServerName.toLatin1())){ partially evaluated: -1 == ::rename(tempPath.toLatin1(), fullServerName.toLatin1())| no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
| 191 | setError(QLatin1String("QLocalServer::listen")); never executed (the execution status of this line is deduced): setError(QLatin1String("QLocalServer::listen")); | - |
| 192 | closeServer(); never executed (the execution status of this line is deduced): closeServer(); | - |
| 193 | return false; never executed: return false; | 0 |
| 194 | } | - |
| 195 | } executed: }Execution Count:4 | 4 |
| 196 | | - |
| 197 | Q_ASSERT(!socketNotifier); executed (the execution status of this line is deduced): qt_noop(); | - |
| 198 | socketNotifier = new QSocketNotifier(listenSocket, executed (the execution status of this line is deduced): socketNotifier = new QSocketNotifier(listenSocket, | - |
| 199 | QSocketNotifier::Read, q); executed (the execution status of this line is deduced): QSocketNotifier::Read, q); | - |
| 200 | q->connect(socketNotifier, SIGNAL(activated(int)), executed (the execution status of this line is deduced): q->connect(socketNotifier, "2""activated(int)", | - |
| 201 | q, SLOT(_q_onNewConnection())); executed (the execution status of this line is deduced): q, "1""_q_onNewConnection()"); | - |
| 202 | socketNotifier->setEnabled(maxPendingConnections > 0); executed (the execution status of this line is deduced): socketNotifier->setEnabled(maxPendingConnections > 0); | - |
| 203 | return true; executed: return true;Execution Count:42 | 42 |
| 204 | } | - |
| 205 | | - |
| 206 | bool QLocalServerPrivate::listen(qintptr socketDescriptor) | - |
| 207 | { | - |
| 208 | Q_Q(QLocalServer); executed (the execution status of this line is deduced): QLocalServer * const q = q_func(); | - |
| 209 | | - |
| 210 | // Attach to the localsocket | - |
| 211 | listenSocket = socketDescriptor; executed (the execution status of this line is deduced): listenSocket = socketDescriptor; | - |
| 212 | | - |
| 213 | ::fcntl(listenSocket, F_SETFD, FD_CLOEXEC); executed (the execution status of this line is deduced): ::fcntl(listenSocket, 2, 1); | - |
| 214 | ::fcntl(listenSocket, F_SETFL, ::fcntl(listenSocket, F_GETFL) | O_NONBLOCK); executed (the execution status of this line is deduced): ::fcntl(listenSocket, 4, ::fcntl(listenSocket, 3) | 04000); | - |
| 215 | | - |
| 216 | #ifdef Q_OS_LINUX | - |
| 217 | struct ::sockaddr_un addr; executed (the execution status of this line is deduced): struct ::sockaddr_un addr; | - |
| 218 | QT_SOCKLEN_T len = sizeof(addr); executed (the execution status of this line is deduced): socklen_t len = sizeof(addr); | - |
| 219 | memset(&addr, 0, sizeof(addr)); executed (the execution status of this line is deduced): memset(&addr, 0, sizeof(addr)); | - |
| 220 | if (0 == ::getsockname(listenSocket, (sockaddr *)&addr, &len)) { partially evaluated: 0 == ::getsockname(listenSocket, (sockaddr *)&addr, &len)| yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
| 221 | // check for absract sockets | - |
| 222 | if (addr.sun_family == PF_UNIX && addr.sun_path[0] == 0) { partially evaluated: addr.sun_family == 1| yes Evaluation Count:4 | no Evaluation Count:0 |
evaluated: addr.sun_path[0] == 0| yes Evaluation Count:3 | yes Evaluation Count:1 |
| 0-4 |
| 223 | addr.sun_path[0] = '@'; executed (the execution status of this line is deduced): addr.sun_path[0] = '@'; | - |
| 224 | } executed: }Execution Count:3 | 3 |
| 225 | QString name = QString::fromLatin1(addr.sun_path); executed (the execution status of this line is deduced): QString name = QString::fromLatin1(addr.sun_path); | - |
| 226 | if (!name.isEmpty()) { partially evaluated: !name.isEmpty()| yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
| 227 | fullServerName = name; executed (the execution status of this line is deduced): fullServerName = name; | - |
| 228 | serverName = fullServerName.mid(fullServerName.lastIndexOf(QLatin1String("/"))+1); executed (the execution status of this line is deduced): serverName = fullServerName.mid(fullServerName.lastIndexOf(QLatin1String("/"))+1); | - |
| 229 | if (serverName.isEmpty()) { partially evaluated: serverName.isEmpty()| no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
| 230 | serverName = fullServerName; never executed (the execution status of this line is deduced): serverName = fullServerName; | - |
| 231 | } | 0 |
| 232 | } executed: }Execution Count:4 | 4 |
| 233 | } executed: }Execution Count:4 | 4 |
| 234 | #else | - |
| 235 | serverName.clear(); | - |
| 236 | fullServerName.clear(); | - |
| 237 | #endif | - |
| 238 | | - |
| 239 | Q_ASSERT(!socketNotifier); executed (the execution status of this line is deduced): qt_noop(); | - |
| 240 | socketNotifier = new QSocketNotifier(listenSocket, executed (the execution status of this line is deduced): socketNotifier = new QSocketNotifier(listenSocket, | - |
| 241 | QSocketNotifier::Read, q); executed (the execution status of this line is deduced): QSocketNotifier::Read, q); | - |
| 242 | q->connect(socketNotifier, SIGNAL(activated(int)), executed (the execution status of this line is deduced): q->connect(socketNotifier, "2""activated(int)", | - |
| 243 | q, SLOT(_q_onNewConnection())); executed (the execution status of this line is deduced): q, "1""_q_onNewConnection()"); | - |
| 244 | socketNotifier->setEnabled(maxPendingConnections > 0); executed (the execution status of this line is deduced): socketNotifier->setEnabled(maxPendingConnections > 0); | - |
| 245 | return true; executed: return true;Execution Count:4 | 4 |
| 246 | } | - |
| 247 | | - |
| 248 | /*! | - |
| 249 | \internal | - |
| 250 | | - |
| 251 | \sa QLocalServer::closeServer() | - |
| 252 | */ | - |
| 253 | void QLocalServerPrivate::closeServer() | - |
| 254 | { | - |
| 255 | if (socketNotifier) { evaluated: socketNotifier| yes Evaluation Count:46 | yes Evaluation Count:1 |
| 1-46 |
| 256 | socketNotifier->setEnabled(false); // Otherwise, closed socket is checked before deleter runs executed (the execution status of this line is deduced): socketNotifier->setEnabled(false); | - |
| 257 | socketNotifier->deleteLater(); executed (the execution status of this line is deduced): socketNotifier->deleteLater(); | - |
| 258 | socketNotifier = 0; executed (the execution status of this line is deduced): socketNotifier = 0; | - |
| 259 | } executed: }Execution Count:46 | 46 |
| 260 | | - |
| 261 | if (-1 != listenSocket) partially evaluated: -1 != listenSocket| yes Evaluation Count:47 | no Evaluation Count:0 |
| 0-47 |
| 262 | QT_CLOSE(listenSocket); executed: qt_safe_close(listenSocket);Execution Count:47 | 47 |
| 263 | listenSocket = -1; executed (the execution status of this line is deduced): listenSocket = -1; | - |
| 264 | | - |
| 265 | if (!fullServerName.isEmpty()) partially evaluated: !fullServerName.isEmpty()| yes Evaluation Count:47 | no Evaluation Count:0 |
| 0-47 |
| 266 | QFile::remove(fullServerName); executed: QFile::remove(fullServerName);Execution Count:47 | 47 |
| 267 | } executed: }Execution Count:47 | 47 |
| 268 | | - |
| 269 | /*! | - |
| 270 | \internal | - |
| 271 | | - |
| 272 | We have received a notification that we can read on the listen socket. | - |
| 273 | Accept the new socket. | - |
| 274 | */ | - |
| 275 | void QLocalServerPrivate::_q_onNewConnection() | - |
| 276 | { | - |
| 277 | Q_Q(QLocalServer); executed (the execution status of this line is deduced): QLocalServer * const q = q_func(); | - |
| 278 | if (-1 == listenSocket) partially evaluated: -1 == listenSocket| no Evaluation Count:0 | yes Evaluation Count:71 |
| 0-71 |
| 279 | return; | 0 |
| 280 | | - |
| 281 | ::sockaddr_un addr; executed (the execution status of this line is deduced): ::sockaddr_un addr; | - |
| 282 | QT_SOCKLEN_T length = sizeof(sockaddr_un); executed (the execution status of this line is deduced): socklen_t length = sizeof(sockaddr_un); | - |
| 283 | int connectedSocket = qt_safe_accept(listenSocket, (sockaddr *)&addr, &length); executed (the execution status of this line is deduced): int connectedSocket = qt_safe_accept(listenSocket, (sockaddr *)&addr, &length); | - |
| 284 | if(-1 == connectedSocket) { partially evaluated: -1 == connectedSocket| no Evaluation Count:0 | yes Evaluation Count:71 |
| 0-71 |
| 285 | setError(QLatin1String("QLocalSocket::activated")); never executed (the execution status of this line is deduced): setError(QLatin1String("QLocalSocket::activated")); | - |
| 286 | closeServer(); never executed (the execution status of this line is deduced): closeServer(); | - |
| 287 | } else { | 0 |
| 288 | socketNotifier->setEnabled(pendingConnections.size() executed (the execution status of this line is deduced): socketNotifier->setEnabled(pendingConnections.size() | - |
| 289 | <= maxPendingConnections); executed (the execution status of this line is deduced): <= maxPendingConnections); | - |
| 290 | q->incomingConnection(connectedSocket); executed (the execution status of this line is deduced): q->incomingConnection(connectedSocket); | - |
| 291 | } executed: }Execution Count:71 | 71 |
| 292 | } | - |
| 293 | | - |
| 294 | void QLocalServerPrivate::waitForNewConnection(int msec, bool *timedOut) | - |
| 295 | { | - |
| 296 | fd_set readfds; executed (the execution status of this line is deduced): fd_set readfds; | - |
| 297 | FD_ZERO(&readfds); executed: }Execution Count:73 partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:73 |
| 0-73 |
| 298 | FD_SET(listenSocket, &readfds); executed (the execution status of this line is deduced): (((&readfds)->fds_bits)[((listenSocket) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) 1 << ((listenSocket) % (8 * (int) sizeof (__fd_mask))))); | - |
| 299 | | - |
| 300 | timeval timeout; executed (the execution status of this line is deduced): timeval timeout; | - |
| 301 | timeout.tv_sec = msec / 1000; executed (the execution status of this line is deduced): timeout.tv_sec = msec / 1000; | - |
| 302 | timeout.tv_usec = (msec % 1000) * 1000; executed (the execution status of this line is deduced): timeout.tv_usec = (msec % 1000) * 1000; | - |
| 303 | | - |
| 304 | int result = -1; executed (the execution status of this line is deduced): int result = -1; | - |
| 305 | result = qt_safe_select(listenSocket + 1, &readfds, 0, 0, (msec == -1) ? 0 : &timeout); executed (the execution status of this line is deduced): result = qt_safe_select(listenSocket + 1, &readfds, 0, 0, (msec == -1) ? 0 : &timeout); | - |
| 306 | if (-1 == result) { partially evaluated: -1 == result| no Evaluation Count:0 | yes Evaluation Count:73 |
| 0-73 |
| 307 | setError(QLatin1String("QLocalServer::waitForNewConnection")); never executed (the execution status of this line is deduced): setError(QLatin1String("QLocalServer::waitForNewConnection")); | - |
| 308 | closeServer(); never executed (the execution status of this line is deduced): closeServer(); | - |
| 309 | } | 0 |
| 310 | if (result > 0) evaluated: result > 0| yes Evaluation Count:71 | yes Evaluation Count:2 |
| 2-71 |
| 311 | _q_onNewConnection(); executed: _q_onNewConnection();Execution Count:71 | 71 |
| 312 | if (timedOut) evaluated: timedOut| yes Evaluation Count:54 | yes Evaluation Count:19 |
| 19-54 |
| 313 | *timedOut = (result == 0); executed: *timedOut = (result == 0);Execution Count:54 | 54 |
| 314 | } executed: }Execution Count:73 | 73 |
| 315 | | - |
| 316 | void QLocalServerPrivate::setError(const QString &function) | - |
| 317 | { | - |
| 318 | if (EAGAIN == errno) partially evaluated: 11 == (*__errno_location ())| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 319 | return; | 0 |
| 320 | | - |
| 321 | switch (errno) { | - |
| 322 | case EACCES: | - |
| 323 | errorString = QLocalServer::tr("%1: Permission denied").arg(function); never executed (the execution status of this line is deduced): errorString = QLocalServer::tr("%1: Permission denied").arg(function); | - |
| 324 | error = QAbstractSocket::SocketAccessError; never executed (the execution status of this line is deduced): error = QAbstractSocket::SocketAccessError; | - |
| 325 | break; | 0 |
| 326 | case ELOOP: | - |
| 327 | case ENOENT: | - |
| 328 | case ENAMETOOLONG: | - |
| 329 | case EROFS: | - |
| 330 | case ENOTDIR: | - |
| 331 | errorString = QLocalServer::tr("%1: Name error").arg(function); executed (the execution status of this line is deduced): errorString = QLocalServer::tr("%1: Name error").arg(function); | - |
| 332 | error = QAbstractSocket::HostNotFoundError; executed (the execution status of this line is deduced): error = QAbstractSocket::HostNotFoundError; | - |
| 333 | break; executed: break;Execution Count:1 | 1 |
| 334 | case EADDRINUSE: | - |
| 335 | errorString = QLocalServer::tr("%1: Address in use").arg(function); executed (the execution status of this line is deduced): errorString = QLocalServer::tr("%1: Address in use").arg(function); | - |
| 336 | error = QAbstractSocket::AddressInUseError; executed (the execution status of this line is deduced): error = QAbstractSocket::AddressInUseError; | - |
| 337 | break; executed: break;Execution Count:1 | 1 |
| 338 | | - |
| 339 | default: | - |
| 340 | errorString = QLocalServer::tr("%1: Unknown error %2") never executed (the execution status of this line is deduced): errorString = QLocalServer::tr("%1: Unknown error %2") | - |
| 341 | .arg(function).arg(errno); never executed (the execution status of this line is deduced): .arg(function).arg((*__errno_location ())); | - |
| 342 | error = QAbstractSocket::UnknownSocketError; never executed (the execution status of this line is deduced): error = QAbstractSocket::UnknownSocketError; | - |
| 343 | #if defined QLOCALSERVER_DEBUG | - |
| 344 | qWarning() << errorString << "fullServerName:" << fullServerName; | - |
| 345 | #endif | - |
| 346 | } | 0 |
| 347 | } executed: }Execution Count:2 | 2 |
| 348 | | - |
| 349 | QT_END_NAMESPACE | - |
| 350 | | - |
| 351 | #endif // QT_NO_LOCALSERVER | - |
| 352 | | - |
| | |