Changeset 561 for trunk/src/network/socket/qlocalserver_unix.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/network/socket/qlocalserver_unix.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information ([email protected]) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation ([email protected]) 5 6 ** 6 7 ** This file is part of the QtNetwork module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you 37 ** @nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 44 44 #include "qlocalsocket.h" 45 45 #include "qlocalsocket_p.h" 46 46 47 47 48 #ifndef QT_NO_LOCALSERVER … … 53 54 #include <qdir.h> 54 55 #include <qdatetime.h> 56 57 58 59 55 60 56 61 QT_BEGIN_NAMESPACE … … 89 94 90 95 // create the unix socket 91 listenSocket = q Socket(PF_UNIX, SOCK_STREAM, 0);96 listenSocket = qocket(PF_UNIX, SOCK_STREAM, 0); 92 97 if (-1 == listenSocket) { 93 98 setError(QLatin1String("QLocalServer::listen")); … … 107 112 fullServerName.toLatin1().size() + 1); 108 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 109 132 // bind 110 if(-1 == qBind(listenSocket, (sockaddr *)&addr, sizeof(sockaddr_un))) {133 if(-1 == (listenSocket, (sockaddr *)&addr, sizeof(sockaddr_un))) { 111 134 setError(QLatin1String("QLocalServer::listen")); 112 135 // if address is in use already, just close the socket, but do not delete the file … … 121 144 122 145 // listen for connections 123 if (-1 == q Listen(listenSocket, 50)) {146 if (-1 == qisten(listenSocket, 50)) { 124 147 setError(QLatin1String("QLocalServer::listen")); 125 148 closeServer(); … … 133 156 QSocketNotifier::Read, q); 134 157 q->connect(socketNotifier, SIGNAL(activated(int)), 135 q, SLOT(_q_ socketActivated()));158 q, SLOT(_q_())); 136 159 socketNotifier->setEnabled(maxPendingConnections > 0); 137 160 return true; … … 149 172 listenSocket = -1; 150 173 151 if (socketNotifier) 174 if (socketNotifier) { 175 socketNotifier->setEnabled(false); // Otherwise, closed socket is checked before deleter runs 152 176 socketNotifier->deleteLater(); 153 socketNotifier = 0; 177 socketNotifier = 0; 178 } 154 179 155 180 if (!fullServerName.isEmpty()) … … 163 188 Accept the new socket. 164 189 */ 165 void QLocalServerPrivate::_q_ socketActivated()190 void QLocalServerPrivate::_q_() 166 191 { 167 192 Q_Q(QLocalServer); … … 171 196 ::sockaddr_un addr; 172 197 QT_SOCKLEN_T length = sizeof(sockaddr_un); 173 int connectedSocket = q Accept(listenSocket, (sockaddr *)&addr, &length);198 int connectedSocket = qccept(listenSocket, (sockaddr *)&addr, &length); 174 199 if(-1 == connectedSocket) { 175 200 setError(QLatin1String("QLocalSocket::activated")); … … 192 217 timeout.tv_usec = (msec % 1000) * 1000; 193 218 194 // timeout can not be 0 or else select will return an error.195 if (0 == msec)196 timeout.tv_usec = 1000;197 198 219 int result = -1; 199 // on Linux timeout will be updated by select, but _not_ on other systems. 200 QTime timer; 201 timer.start(); 202 while (pendingConnections.isEmpty() && (-1 == msec || timer.elapsed() < msec)) { 203 result = ::select(listenSocket + 1, &readfds, 0, 0, &timeout); 204 if (-1 == result && errno != EINTR) { 205 setError(QLatin1String("QLocalServer::waitForNewConnection")); 206 closeServer(); 207 break; 208 } 209 if (result > 0) 210 _q_socketActivated(); 211 } 220 result = qt_safe_select(listenSocket + 1, &readfds, 0, 0, (msec == -1) ? 0 : &timeout); 221 if (-1 == result) { 222 setError(QLatin1String("QLocalServer::waitForNewConnection")); 223 closeServer(); 224 } 225 if (result > 0) 226 _q_onNewConnection(); 212 227 if (timedOut) 213 228 *timedOut = (result == 0);
Note:
See TracChangeset
for help on using the changeset viewer.