diff --git a/ChangeLog.txt b/ChangeLog.txt index dd7ec248..a705ca97 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -8,6 +8,7 @@ Broker: - Fix bridge not reconnectng if the first reconnection attempt fails. Closes #2207. - Improve QoS 0 outgoing packet queueing. +- Fix non-reachable bridge blocking the broker on Windows. Closes #2172. Clients: - If sending mosquitto_sub output to a pipe, mosquitto_sub will now detect diff --git a/lib/packet_mosq.c b/lib/packet_mosq.c index d9647182..bce1fe8b 100644 --- a/lib/packet_mosq.c +++ b/lib/packet_mosq.c @@ -236,11 +236,7 @@ int packet__write(struct mosquitto *mosq) #endif state = mosquitto__get_state(mosq); -#if defined(WITH_TLS) && !defined(WITH_BROKER) if(state == mosq_cs_connect_pending || mosq->want_connect){ -#else - if(state == mosq_cs_connect_pending){ -#endif pthread_mutex_unlock(&mosq->current_out_packet_mutex); return MOSQ_ERR_SUCCESS; } @@ -324,15 +320,17 @@ int packet__write(struct mosquitto *mosq) #ifdef WITH_BROKER mosq->next_msg_out = db.now_s + mosq->keepalive; - if(mosq->current_out_packet == NULL){ - mux__remove_out(mosq); - } #else pthread_mutex_lock(&mosq->msgtime_mutex); mosq->next_msg_out = mosquitto_time() + mosq->keepalive; pthread_mutex_unlock(&mosq->msgtime_mutex); #endif } +#ifdef WITH_BROKER + if (mosq->current_out_packet == NULL) { + mux__remove_out(mosq); + } +#endif pthread_mutex_unlock(&mosq->current_out_packet_mutex); return MOSQ_ERR_SUCCESS; } diff --git a/src/bridge.c b/src/bridge.c index 3fc0dce8..bb7b9c35 100644 --- a/src/bridge.c +++ b/src/bridge.c @@ -285,6 +285,7 @@ int bridge__connect_step2(struct mosquitto *context) if(rc == MOSQ_ERR_CONN_PENDING){ mosquitto__set_state(context, mosq_cs_connect_pending); + mux__add_out(context); } return rc; } @@ -447,6 +448,7 @@ int bridge__connect(struct mosquitto *context) return rc; }else if(rc == MOSQ_ERR_CONN_PENDING){ mosquitto__set_state(context, mosq_cs_connect_pending); + mux__add_out(context); } HASH_ADD(hh_sock, db.contexts_by_sock, sock, sizeof(context->sock), context);