Fix a deadlock when shutting down during discovery (#4993)
authorJocelyn Turcotte <jturcotte@woboq.com>
Mon, 27 Jun 2016 14:12:39 +0000 (16:12 +0200)
committerMarkus Goetz <markus@woboq.com>
Mon, 27 Jun 2016 14:12:39 +0000 (16:12 +0200)
Since the SyncEngine now quits and waits for the discovery thread,
the main thread can enter a deadlock where the discovery thread waits
for its directory result.

Add a 2 seconds timer to the discovery thread wait condition
to limit the deadlock time.

src/libsync/discoveryphase.cpp

index c85fe2d3c4141ae6e4d02175aae3070a3d40f0c9..52a454e9cb9a5f26e294bf0d41513cafe11b8917 100644 (file)
@@ -564,7 +564,7 @@ csync_vio_handle_t* DiscoveryJob::remote_vio_opendir_hook (const char *url,
         discoveryJob->_vioMutex.lock();
         const QString qurl = QString::fromUtf8(url);
         emit discoveryJob->doOpendirSignal(qurl, directoryResult.data());
-        discoveryJob->_vioWaitCondition.wait(&discoveryJob->_vioMutex, ULONG_MAX); // FIXME timeout?
+        discoveryJob->_vioWaitCondition.wait(&discoveryJob->_vioMutex, 30000);
         discoveryJob->_vioMutex.unlock();
 
         qDebug() << discoveryJob << url << "...Returned from main thread";