Skip to content

Commit

Permalink
Fix mosquitto_pub -l quitting if broker unavailable.
Browse files Browse the repository at this point in the history
This could occur when a message publication is attempted when the broker
is temporarily unavailable.

Closes #2187. Thanks to JsBergbau.
  • Loading branch information
ralight committed May 8, 2021
1 parent c8cd359 commit 07399c2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 2 additions & 0 deletions ChangeLog.txt
Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions client/pub_client.c
Expand Up @@ -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{
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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));
}
}
Expand Down

0 comments on commit 07399c2

Please sign in to comment.