Changeset 568 for trunk/src/network/socket/qlocalserver_os2.cpp
- Timestamp:
- Feb 13, 2010, 1:10:15 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/network/socket/qlocalserver_os2.cpp
r564 r568 91 91 92 92 // create the unix socket 93 listenSocket = qSocket(PF_UNIX, SOCK_STREAM, 0);93 listenSocket = ocket(PF_UNIX, SOCK_STREAM, 0); 94 94 if (-1 == listenSocket) { 95 95 setError(QLatin1String("QLocalServer::listen")); … … 110 110 111 111 // bind 112 if(-1 == qBind(listenSocket, (sockaddr *)&addr, sizeof(sockaddr_un))) {112 if(-1 == ind(listenSocket, (sockaddr *)&addr, sizeof(sockaddr_un))) { 113 113 setError(QLatin1String("QLocalServer::listen")); 114 114 // if address is in use already, just close the socket, but do not delete the file … … 123 123 124 124 // listen for connections 125 if (-1 == qListen(listenSocket, 50)) {125 if (-1 == isten(listenSocket, 50)) { 126 126 setError(QLatin1String("QLocalServer::listen")); 127 127 closeServer(); … … 135 135 QSocketNotifier::Read, q); 136 136 q->connect(socketNotifier, SIGNAL(activated(int)), 137 q, SLOT(_q_ socketActivated()));137 q, SLOT(_q_())); 138 138 socketNotifier->setEnabled(maxPendingConnections > 0); 139 139 return true; … … 151 151 listenSocket = -1; 152 152 153 if (socketNotifier) 153 if (socketNotifier) { 154 socketNotifier->setEnabled(false); // Otherwise, closed socket is checked before deleter runs 154 155 socketNotifier->deleteLater(); 155 socketNotifier = 0; 156 socketNotifier = 0; 157 } 156 158 157 159 if (!fullServerName.isEmpty()) … … 165 167 Accept the new socket. 166 168 */ 167 void QLocalServerPrivate::_q_ socketActivated()169 void QLocalServerPrivate::_q_() 168 170 { 169 171 Q_Q(QLocalServer); … … 172 174 173 175 ::sockaddr_un addr; 174 QT_SOCKLEN_Tlength = sizeof(sockaddr_un);175 int connectedSocket = qAccept(listenSocket, (sockaddr *)&addr, &length);176 length = sizeof(sockaddr_un); 177 int connectedSocket = ccept(listenSocket, (sockaddr *)&addr, &length); 176 178 if(-1 == connectedSocket) { 177 179 setError(QLatin1String("QLocalSocket::activated")); … … 194 196 timeout.tv_usec = (msec % 1000) * 1000; 195 197 196 // timeout can not be 0 or else select will return an error.197 if (0 == msec)198 timeout.tv_usec = 1000;199 200 198 int result = -1; 201 // on Linux timeout will be updated by select, but _not_ on other systems. 202 QTime timer; 203 timer.start(); 204 while (pendingConnections.isEmpty() && (-1 == msec || timer.elapsed() < msec)) { 205 result = ::select(listenSocket + 1, &readfds, 0, 0, &timeout); 206 if (-1 == result && errno != EINTR) { 207 setError(QLatin1String("QLocalServer::waitForNewConnection")); 208 closeServer(); 209 break; 210 } 211 if (result > 0) 212 _q_socketActivated(); 213 } 199 result = ::select(listenSocket + 1, &readfds, 0, 0, (msec == -1) ? 0 : &timeout); 200 if (-1 == result) { 201 setError(QLatin1String("QLocalServer::waitForNewConnection")); 202 closeServer(); 203 } 204 if (result > 0) 205 _q_onNewConnection(); 214 206 if (timedOut) 215 207 *timedOut = (result == 0);
Note:
See TracChangeset
for help on using the changeset viewer.