mirror of https://github.com/eclipse/paho.mqtt.c
Fix for #754 - lock on socket mutex for getWrite
This commit is contained in:
parent
d9583e48fc
commit
c19bd17c03
|
|
@ -2198,8 +2198,17 @@ MQTTResponse MQTTClient_publish5(MQTTClient handle, const char* topicName, int p
|
|||
*/
|
||||
if (rc == TCPSOCKET_INTERRUPTED)
|
||||
{
|
||||
while (m->c->connected == 1 && SocketBuffer_getWrite(m->c->net.socket))
|
||||
while (m->c->connected == 1)
|
||||
{
|
||||
pending_writes* writing = NULL;
|
||||
|
||||
Thread_lock_mutex(socket_mutex);
|
||||
writing = SocketBuffer_getWrite(m->c->net.socket);
|
||||
Thread_unlock_mutex(socket_mutex);
|
||||
|
||||
if (writing == NULL)
|
||||
break;
|
||||
|
||||
Thread_unlock_mutex(mqttclient_mutex);
|
||||
MQTTClient_yield();
|
||||
Thread_lock_mutex(mqttclient_mutex);
|
||||
|
|
|
|||
Loading…
Reference in New Issue