bug fix for the server (fixed a dead lock)
This commit is contained in:
parent
dcc4f0596f
commit
0d93612214
1 changed files with 19 additions and 8 deletions
|
@ -71,14 +71,25 @@ void CSocket::Init ( const quint16 iPortNumber )
|
||||||
|
|
||||||
// connect the "activated" signal
|
// connect the "activated" signal
|
||||||
#ifdef ENABLE_RECEIVE_SOCKET_IN_SEPARATE_THREAD
|
#ifdef ENABLE_RECEIVE_SOCKET_IN_SEPARATE_THREAD
|
||||||
// We have to use a blocked queued connection since in case we use a
|
if ( bIsClient )
|
||||||
// separate socket thread, the "readyRead" signal would occur and our
|
{
|
||||||
// "OnDataReceived" function would be run in another thread. This could
|
// We have to use a blocked queued connection since in case we use a
|
||||||
// lead to a situation that a new "readRead" occurs while the processing
|
// separate socket thread, the "readyRead" signal would occur and our
|
||||||
// of the previous signal was not finished -> the error: "Multiple
|
// "OnDataReceived" function would be run in another thread. This could
|
||||||
// socket notifiers for same socket" may occur.
|
// lead to a situation that a new "readRead" occurs while the processing
|
||||||
QObject::connect ( &SocketDevice, SIGNAL ( readyRead() ),
|
// of the previous signal was not finished -> the error: "Multiple
|
||||||
this, SLOT ( OnDataReceived() ), Qt::BlockingQueuedConnection );
|
// socket notifiers for same socket" may occur.
|
||||||
|
QObject::connect ( &SocketDevice, SIGNAL ( readyRead() ),
|
||||||
|
this, SLOT ( OnDataReceived() ), Qt::BlockingQueuedConnection );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// the server does not use a separate socket thread right now, in that
|
||||||
|
// case we must not use the blocking queued connection, otherwise we
|
||||||
|
// would get a dead lock
|
||||||
|
QObject::connect ( &SocketDevice, SIGNAL ( readyRead() ),
|
||||||
|
this, SLOT ( OnDataReceived() ) );
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
QObject::connect ( &SocketDevice, SIGNAL ( readyRead() ),
|
QObject::connect ( &SocketDevice, SIGNAL ( readyRead() ),
|
||||||
this, SLOT ( OnDataReceived() ) );
|
this, SLOT ( OnDataReceived() ) );
|
||||||
|
|
Loading…
Reference in a new issue