Fix non-reachable bridge blocking the broker on Windows.

Closes #2172. Thanks to Niclas Lindgren.
pull/2255/head
Roger A. Light 4 years ago
parent 5851713f3e
commit 104b94db57

@ -8,6 +8,7 @@ Broker:
- Fix bridge not reconnectng if the first reconnection attempt fails. - Fix bridge not reconnectng if the first reconnection attempt fails.
Closes #2207. Closes #2207.
- Improve QoS 0 outgoing packet queueing. - Improve QoS 0 outgoing packet queueing.
- Fix non-reachable bridge blocking the broker on Windows. Closes #2172.
Clients: Clients:
- If sending mosquitto_sub output to a pipe, mosquitto_sub will now detect - If sending mosquitto_sub output to a pipe, mosquitto_sub will now detect

@ -236,11 +236,7 @@ int packet__write(struct mosquitto *mosq)
#endif #endif
state = mosquitto__get_state(mosq); state = mosquitto__get_state(mosq);
#if defined(WITH_TLS) && !defined(WITH_BROKER)
if(state == mosq_cs_connect_pending || mosq->want_connect){ 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); pthread_mutex_unlock(&mosq->current_out_packet_mutex);
return MOSQ_ERR_SUCCESS; return MOSQ_ERR_SUCCESS;
} }
@ -324,15 +320,17 @@ int packet__write(struct mosquitto *mosq)
#ifdef WITH_BROKER #ifdef WITH_BROKER
mosq->next_msg_out = db.now_s + mosq->keepalive; mosq->next_msg_out = db.now_s + mosq->keepalive;
if(mosq->current_out_packet == NULL){
mux__remove_out(mosq);
}
#else #else
pthread_mutex_lock(&mosq->msgtime_mutex); pthread_mutex_lock(&mosq->msgtime_mutex);
mosq->next_msg_out = mosquitto_time() + mosq->keepalive; mosq->next_msg_out = mosquitto_time() + mosq->keepalive;
pthread_mutex_unlock(&mosq->msgtime_mutex); pthread_mutex_unlock(&mosq->msgtime_mutex);
#endif #endif
} }
#ifdef WITH_BROKER
if (mosq->current_out_packet == NULL) {
mux__remove_out(mosq);
}
#endif
pthread_mutex_unlock(&mosq->current_out_packet_mutex); pthread_mutex_unlock(&mosq->current_out_packet_mutex);
return MOSQ_ERR_SUCCESS; return MOSQ_ERR_SUCCESS;
} }

@ -285,6 +285,7 @@ int bridge__connect_step2(struct mosquitto *context)
if(rc == MOSQ_ERR_CONN_PENDING){ if(rc == MOSQ_ERR_CONN_PENDING){
mosquitto__set_state(context, mosq_cs_connect_pending); mosquitto__set_state(context, mosq_cs_connect_pending);
mux__add_out(context);
} }
return rc; return rc;
} }
@ -447,6 +448,7 @@ int bridge__connect(struct mosquitto *context)
return rc; return rc;
}else if(rc == MOSQ_ERR_CONN_PENDING){ }else if(rc == MOSQ_ERR_CONN_PENDING){
mosquitto__set_state(context, mosq_cs_connect_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); HASH_ADD(hh_sock, db.contexts_by_sock, sock, sizeof(context->sock), context);

Loading…
Cancel
Save