Commit 45409c00 authored by Juergen Kosel's avatar Juergen Kosel

Mark the socket as not connected before releasing socket_mutex

Issue 190 ( https://github.com/eclipse/paho.mqtt.c/issues/190 ) is
probably caused by some race condition.
One possible cause for such a race condition is in the previous
implementation of MQTTAsync_closeOnly(). Which had released the semaphore
before the socket is marked as unused. This way, another thread may believe,
that it should wait that the socket becomes available (which never happens).
Signed-off-by: 's avatarJuergen Kosel <juergen.kosel@softing.com>
parent c06f3c19
......@@ -1993,11 +1993,11 @@ void MQTTAsync_closeOnly(Clients* client)
SSLSocket_close(&client->net);
#endif
Socket_close(client->net.socket);
Thread_unlock_mutex(socket_mutex);
client->net.socket = 0;
#if defined(OPENSSL)
client->net.ssl = NULL;
#endif
Thread_unlock_mutex(socket_mutex);
}
client->connected = 0;
client->connect_state = 0;
......
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