Commit 34103726 authored by Juergen Kosel's avatar Juergen Kosel

Prevent release socket_mutex during call of select()

As suggested in https://github.com/eclipse/paho.mqtt.c/issues/385#issuecomment-372299490
the socket_mutex is released during the call of select(),
to avoid a performance penalty.
Signed-off-by: 's avatarJuergen Kosel <juergen.kosel@softing.com>
parent 2d255174
...@@ -259,7 +259,11 @@ int Socket_getReadySocket(int more_work, struct timeval *tp, mutex_type mutex) ...@@ -259,7 +259,11 @@ int Socket_getReadySocket(int more_work, struct timeval *tp, mutex_type mutex)
memcpy((void*)&(s.rset), (void*)&(s.rset_saved), sizeof(s.rset)); memcpy((void*)&(s.rset), (void*)&(s.rset_saved), sizeof(s.rset));
memcpy((void*)&(pwset), (void*)&(s.pending_wset), sizeof(pwset)); memcpy((void*)&(pwset), (void*)&(s.pending_wset), sizeof(pwset));
if ((rc = select(s.maxfdp1, &(s.rset), &pwset, NULL, &timeout)) == SOCKET_ERROR) /* Prevent performance issue by unlocking the socket_mutex while waiting for a ready socket. */
Thread_unlock_mutex(mutex);
rc = select(s.maxfdp1, &(s.rset), &pwset, NULL, &timeout);
Thread_lock_mutex(mutex);
if (rc == SOCKET_ERROR)
{ {
Socket_error("read select", 0); Socket_error("read select", 0);
goto exit; goto exit;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment