Fix mosquitto_pub -l quitting if broker unavailable.

This could occur when a message publication is attempted when the broker
is temporarily unavailable.

Closes #2187. Thanks to JsBergbau.
This commit is contained in:
Roger Light 2021-05-08 23:07:02 +01:00
parent c8cd3590f1
commit 07399c2f3c
2 changed files with 5 additions and 5 deletions

View File

@ -9,6 +9,8 @@ Broker:
Clients:
- If sending mosquitto_sub output to a pipe, mosquitto_sub will now detect
that the pipe has closed and disconnect. Closes #2164.
- Fix `mosquitto_pub -l` quitting if a message publication is attempted when
the broker is temporarily unavailable. Closes #2187.
2.0.10 - 2021-04-03

View File

@ -268,9 +268,8 @@ static int pub_stdin_line_loop(struct mosquitto *mosq)
line_buf[buf_len_actual-1] = '\0';
rc = my_publish(mosq, &mid_sent, cfg.topic, buf_len_actual-1, line_buf, cfg.qos, cfg.retain);
pos = 0;
if(rc){
err_printf(&cfg, "Error: Publish returned %d.\n", rc);
if(cfg.qos>0) return rc;
if(rc != MOSQ_ERR_SUCCESS && rc != MOSQ_ERR_NO_CONN){
return rc;
}
break;
}else{
@ -288,7 +287,6 @@ static int pub_stdin_line_loop(struct mosquitto *mosq)
if(pos != 0){
rc = my_publish(mosq, &mid_sent, cfg.topic, buf_len_actual, line_buf, cfg.qos, cfg.retain);
if(rc){
err_printf(&cfg, "Error: Publish returned %d.\n", rc);
if(cfg.qos>0) return rc;
}
}
@ -357,7 +355,7 @@ static int pub_other_loop(struct mosquitto *mosq)
rc = my_publish(mosq, &mid_sent, cfg.topic, 0, NULL, cfg.qos, cfg.retain);
break;
}
if(rc){
if(rc != MOSQ_ERR_SUCCESS && rc != MOSQ_ERR_NO_CONN){
err_printf(&cfg, "Error sending repeat publish: %s", mosquitto_strerror(rc));
}
}