Fix high CPU use on slow TLS connect.
Closes #2794. Thanks to Evgeny S.
This commit is contained in:
parent
3c51816009
commit
269756a171
@ -17,6 +17,7 @@ Client library:
|
||||
problem of the client OS sleeping and the client hence not being able to
|
||||
calculate the actual time for keepalive purposes. Closes #2760.
|
||||
- Fix default settings incorrectly allowing TLS v1.1. Closes #2722.
|
||||
- Fix high CPU use on slow TLS connect. Closes #2794.
|
||||
|
||||
Clients:
|
||||
- Fix incorrect topic-alias property value in mosquitto_sub json output.
|
||||
|
16
lib/loop.c
16
lib/loop.c
@ -63,20 +63,22 @@ int mosquitto_loop(struct mosquitto *mosq, int timeout, int max_packets)
|
||||
if(mosq->sock != INVALID_SOCKET){
|
||||
maxfd = mosq->sock;
|
||||
FD_SET(mosq->sock, &readfds);
|
||||
if(mosq->want_write){
|
||||
FD_SET(mosq->sock, &writefds);
|
||||
}else{
|
||||
#ifdef WITH_TLS
|
||||
if(mosq->ssl == NULL || SSL_is_init_finished(mosq->ssl))
|
||||
#endif
|
||||
{
|
||||
pthread_mutex_lock(&mosq->current_out_packet_mutex);
|
||||
pthread_mutex_lock(&mosq->out_packet_mutex);
|
||||
if(mosq->out_packet || mosq->current_out_packet){
|
||||
FD_SET(mosq->sock, &writefds);
|
||||
}
|
||||
#ifdef WITH_TLS
|
||||
if(mosq->ssl){
|
||||
if(mosq->want_write){
|
||||
FD_SET(mosq->sock, &writefds);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
pthread_mutex_unlock(&mosq->out_packet_mutex);
|
||||
pthread_mutex_unlock(&mosq->current_out_packet_mutex);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
#ifdef WITH_SRV
|
||||
if(mosq->achan){
|
||||
|
@ -332,18 +332,7 @@ int mosquitto_socket(struct mosquitto *mosq)
|
||||
|
||||
bool mosquitto_want_write(struct mosquitto *mosq)
|
||||
{
|
||||
bool result = false;
|
||||
if(mosq->out_packet || mosq->current_out_packet){
|
||||
result = true;
|
||||
}
|
||||
#ifdef WITH_TLS
|
||||
if(mosq->ssl){
|
||||
if (mosq->want_write) {
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return result;
|
||||
return mosq->out_packet || mosq->current_out_packet || mosq->want_write;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user