don't deadlock, could happen on error

i.e. if we tried to listen to an already used port, the error
was propagated in the main thread and the blockingqueuedconnection
would deadlock. not anymore
1.4
Milian Wolff 2011-11-07 18:25:38 +01:00
parent 36e8a3e87c
commit 667c585424
1 changed files with 5 additions and 1 deletions

View File

@ -44,7 +44,11 @@ static void *callback(mg_event event,
// note: we use a blocking queued connection to always handle the request in the main thread
// TODO: check whether direct call works as well
bool handled = false;
QMetaObject::invokeMethod(server, "handleRequest", Qt::BlockingQueuedConnection,
Qt::ConnectionType connectionType = Qt::DirectConnection;
if (QThread::currentThread() != server->thread()) {
connectionType = Qt::BlockingQueuedConnection;
}
QMetaObject::invokeMethod(server, "handleRequest", connectionType,
Q_ARG(mg_event, event), Q_ARG(mg_connection*, conn),
Q_ARG(const mg_request_info*, request_info),
Q_ARG(bool*, &handled));