src/network/socket/qlocalserver_unix.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
   214 
   214 
   215     timeval timeout;
   215     timeval timeout;
   216     timeout.tv_sec = msec / 1000;
   216     timeout.tv_sec = msec / 1000;
   217     timeout.tv_usec = (msec % 1000) * 1000;
   217     timeout.tv_usec = (msec % 1000) * 1000;
   218 
   218 
   219     // timeout can not be 0 or else select will return an error.
       
   220     if (0 == msec)
       
   221         timeout.tv_usec = 1000;
       
   222 
       
   223     int result = -1;
   219     int result = -1;
   224     // on Linux timeout will be updated by select, but _not_ on other systems.
   220     result = qt_safe_select(listenSocket + 1, &readfds, 0, 0, (msec == -1) ? 0 : &timeout);
   225     QTime timer;
   221     if (-1 == result) {
   226     timer.start();
   222         setError(QLatin1String("QLocalServer::waitForNewConnection"));
   227     while (pendingConnections.isEmpty() && (-1 == msec || timer.elapsed() < msec)) {
   223         closeServer();
   228         result = ::select(listenSocket + 1, &readfds, 0, 0, &timeout);
   224     }
   229         if (-1 == result && errno != EINTR) {
   225     if (result > 0)
   230             setError(QLatin1String("QLocalServer::waitForNewConnection"));
   226         _q_onNewConnection();
   231             closeServer();
       
   232             break;
       
   233         }
       
   234         if (result > 0)
       
   235             _q_onNewConnection();
       
   236     }
       
   237     if (timedOut)
   227     if (timedOut)
   238         *timedOut = (result == 0);
   228         *timedOut = (result == 0);
   239 }
   229 }
   240 
   230 
   241 void QLocalServerPrivate::setError(const QString &function)
   231 void QLocalServerPrivate::setError(const QString &function)