diff options
author | Robert Knight <robert.knight@mendeley.com> | 2011-11-18 17:07:21 (GMT) |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2011-11-18 17:09:47 (GMT) |
commit | a9c3f7169faf4621d39714f753d6e8b376c5d6e5 (patch) | |
tree | eee9809a9b0b840c8f30527fdc27096485319558 /src/network | |
parent | b68b59f252930538cc124b31decc990ab57bea20 (diff) | |
download | Qt-a9c3f7169faf4621d39714f753d6e8b376c5d6e5.zip Qt-a9c3f7169faf4621d39714f753d6e8b376c5d6e5.tar.gz Qt-a9c3f7169faf4621d39714f753d6e8b376c5d6e5.tar.bz2 |
Fix sporadic hang in QLocalServer::close() in OS X 10.7
There is a bug in CFSocket/CFRunLoopSource in OS X 10.7 which can lead to a deadlock
in CFRunLoopRemoveSource or CFRunLoopSourceInvalidate if the CFSocket manager thread
is concurrently calling CFSocketInvalidate as a result of the socket's file descriptor
having been closed.
QLocalServer::close() triggers this race by closing the socket fd before unregistering
the QSocketNotifier, which internally uses CFSocket.
This commit fixes the problem by changing the ordering in close() so that the socket notifier
is disabled before closing the file descriptor. This change also makes QLocalServer::close()
perform operations in reverse order to QLocalServer::listen(), as would be expected.
Task-number: QTBUG-22789
Merge-request: 1470
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/socket/qlocalserver_unix.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/network/socket/qlocalserver_unix.cpp b/src/network/socket/qlocalserver_unix.cpp index 851e898..390712c 100644 --- a/src/network/socket/qlocalserver_unix.cpp +++ b/src/network/socket/qlocalserver_unix.cpp @@ -167,16 +167,16 @@ bool QLocalServerPrivate::listen(const QString &requestedServerName) */ void QLocalServerPrivate::closeServer() { - if (-1 != listenSocket) - QT_CLOSE(listenSocket); - listenSocket = -1; - if (socketNotifier) { socketNotifier->setEnabled(false); // Otherwise, closed socket is checked before deleter runs socketNotifier->deleteLater(); socketNotifier = 0; } + if (-1 != listenSocket) + QT_CLOSE(listenSocket); + listenSocket = -1; + if (!fullServerName.isEmpty()) QFile::remove(fullServerName); } |