Fix TLS connections when using an external event loop.

Affects the use of mosquitto_loop_read() and mosquitto_write().
Closes #990.
pull/1029/head
Roger A. Light 7 years ago
parent b803b40a22
commit 71b8c4d892

@ -15,7 +15,9 @@ Broker:
Library:
- Fix memory leak that occurred if mosquitto_reconnect() was used when TLS
errors were present. Closes #592.
errors were present. Closes #592.
- Fix TLS connections when using an external event loop with
mosquitto_loop_read() and mosquitto_write(). Closes #990.
Build:
- Fix clients not being compiled with threading support when using CMake.

@ -147,20 +147,12 @@ int mosquitto_loop(struct mosquitto *mosq, int timeout, int max_packets)
}else{
if(mosq->sock != INVALID_SOCKET){
if(FD_ISSET(mosq->sock, &readfds)){
#ifdef WITH_TLS
if(mosq->want_connect){
rc = net__socket_connect_tls(mosq);
if(rc) return rc;
}else
#endif
{
do{
rc = mosquitto_loop_read(mosq, max_packets);
if(rc || mosq->sock == INVALID_SOCKET){
return rc;
}
}while(SSL_DATA_PENDING(mosq));
}
do{
rc = mosquitto_loop_read(mosq, max_packets);
if(rc || mosq->sock == INVALID_SOCKET){
return rc;
}
}while(SSL_DATA_PENDING(mosq));
}
if(mosq->sockpairR != INVALID_SOCKET && FD_ISSET(mosq->sockpairR, &readfds)){
#ifndef WIN32
@ -354,6 +346,12 @@ int mosquitto_loop_read(struct mosquitto *mosq, int max_packets)
int i;
if(max_packets < 1) return MOSQ_ERR_INVAL;
#ifdef WITH_TLS
if(mosq->want_connect){
return net__socket_connect_tls(mosq);
}
#endif
pthread_mutex_lock(&mosq->out_message_mutex);
max_packets = mosq->out_queue_len;
pthread_mutex_unlock(&mosq->out_message_mutex);

Loading…
Cancel
Save