Changeset 755
- Timestamp:
- Jun 22, 2010, 1:13:59 PM (15 years ago)
- Location:
- trunk/src/network/socket
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/network/socket/qlocalserver.cpp
r651 r755 201 201 Usually you would just pass in a name like "foo", but on Unix this 202 202 could also be a path such as "/tmp/foo" and on Windows this could 203 be a pipe path such as "\\\\.\\pipe\\foo" 203 be a pipe path such as "\\\\.\\pipe\\foo". On OS/2, "\\socket\\" is 204 automatically prepended to the name if it does not already sttart with 205 this prefix. 204 206 205 207 Note: … … 298 300 instance has not been cleaned up. 299 301 300 On Windows , this function does nothing; on Unix, it removes the socket file301 given by \a name.302 On Windowse 303 given by \a name. 302 304 303 305 \warning Be careful to avoid removing sockets of running instances. -
trunk/src/network/socket/qlocalserver_os2.cpp
r754 r755 64 64 bool QLocalServerPrivate::removeServer(const QString &name) 65 65 { 66 QString fileName; 67 if (name.startsWith(QLatin1Char('/'))) { 68 fileName = name; 69 } else { 70 fileName = QDir::cleanPath(QDir::tempPath()); 71 fileName += QLatin1Char('/') + name; 72 } 73 if (QFile::exists(fileName)) 74 return QFile::remove(fileName); 75 else 76 return true; 66 Q_UNUSED(name); 67 return true; 77 68 } 78 69 … … 81 72 Q_Q(QLocalServer); 82 73 74 75 76 83 77 // determine the full server path 84 if (requestedServerName.startsWith(QLatin1Char('/'))) { 85 fullServerName = requestedServerName; 86 } else { 87 fullServerName = QDir::cleanPath(QDir::tempPath()); 88 fullServerName += QLatin1Char('/') + requestedServerName; 78 fullServerName = QDir::toNativeSeparators(requestedServerName); 79 if (!fullServerName.startsWith(socketPath)) { 80 fullServerName = socketPath + requestedServerName; 89 81 } 90 82 serverName = requestedServerName; … … 101 93 struct ::sockaddr_un addr; 102 94 addr.sun_family = PF_UNIX; 103 if (sizeof(addr.sun_path) < (uint)fullServerName.toLatin1().size() + 1) { 104 setError(QLatin1String("QLocalServer::listen")); 105 closeServer(); 106 return false; 107 } 108 ::memcpy(addr.sun_path, fullServerName.toLatin1().data(), 109 fullServerName.toLatin1().size() + 1); 95 addr.sun_len = sizeof(sockaddr_un); 96 QByteArray fsn = fullServerName.toLocal8Bit(); 97 if (sizeof(addr.sun_path) < (uint)fsn.size() + 1) { 98 errno = E2BIG; // indicate buffer overflow 99 setError(QLatin1String("QLocalServer::listen")); 100 closeServer(); 101 return false; 102 } 103 ::strcpy(addr.sun_path, fsn); 110 104 111 105 // bind … … 127 121 closeServer(); 128 122 listenSocket = -1; 129 if (error != QAbstractSocket::AddressInUseError)130 QFile::remove(fullServerName);131 123 return false; 132 124 } … … 151 143 socketNotifier = 0; 152 144 } 153 154 if (!fullServerName.isEmpty())155 QFile::remove(fullServerName);156 145 } 157 146 -
trunk/src/network/socket/qlocalsocket.cpp
r651 r755 53 53 \brief The QLocalSocket class provides a local socket. 54 54 55 On Windows this is a named pipe and on Unix this is a local domain socket. 55 On Windows this is a named pipe, on Unix and OS/2 this is a local domain 56 socket. 56 57 57 58 If an error occurs, socketError() returns the type of error, and -
trunk/src/network/socket/qlocalsocket_os2.cpp
r754 r755 271 271 QString connectingPathName; 272 272 273 274 275 273 276 // determine the full server path 274 if (connectingName.startsWith(QLatin1Char('/'))) { 275 connectingPathName = connectingName; 276 } else { 277 connectingPathName = QDir::tempPath(); 278 connectingPathName += QLatin1Char('/') + connectingName; 277 connectingPathName = QDir::toNativeSeparators(connectingName); 278 if (!connectingName.startsWith(socketPath)) { 279 connectingPathName = socketPath + connectingName; 279 280 } 280 281 281 282 struct sockaddr_un name; 282 283 name.sun_family = PF_UNIX; 283 if (sizeof(name.sun_path) < (uint)connectingPathName.toLatin1().size() + 1) { 284 name.sun_len = sizeof(sockaddr_un); 285 QByteArray cpn = connectingPathName.toLocal8Bit(); 286 if (sizeof(name.sun_path) < (uint)cpn.size() + 1) { 284 287 QString function = QLatin1String("QLocalSocket::connectToServer"); 285 288 errorOccurred(QLocalSocket::ServerNotFoundError, function); 286 289 return; 287 290 } 288 :: memcpy(name.sun_path, connectingPathName.toLatin1().data(),289 connectingPathName.toLatin1().size() + 1); 291 :: 292 290 293 if (-1 == ::connect(connectingSocket, (struct sockaddr *)&name, sizeof(name))) { 291 294 QString function = QLatin1String("QLocalSocket::connectToServer");
Note:
See TracChangeset
for help on using the changeset viewer.