@ -936,7 +936,7 @@ int mosquitto_loop_forever(struct mosquitto *mosq, int timeout, int max_packets)
if (reconnects !=0 && rc == MOSQ_ERR_SUCCESS){
reconnects = 0;
}
}while(rc == MOSQ_ERR_SUCCESS);
}while(run && rc == MOSQ_ERR_SUCCESS);
if(errno == EPROTO){
return rc;
@ -43,7 +43,9 @@ int _mosquitto_handle_connack(struct mosquitto *mosq)
pthread_mutex_unlock(&mosq->callback_mutex);
switch(result){
case 0:
mosq->state = mosq_cs_connected;
if(mosq->state != mosq_cs_disconnecting){
return MOSQ_ERR_SUCCESS;
case 1:
case 2: