Fix mosquitto_sub being unable to terminate with Ctrl-C.
This occured if a successful connection was not made. Closes #1957. Thanks to Peoh.
This commit is contained in:
parent
7a7fe8b80a
commit
de141540fb
@ -4,6 +4,10 @@ Broker:
|
|||||||
- Fix LWT not being sent on client takeover when the existing session wasn't
|
- Fix LWT not being sent on client takeover when the existing session wasn't
|
||||||
being continued. Closes #1946.
|
being continued. Closes #1946.
|
||||||
|
|
||||||
|
Clients:
|
||||||
|
- Fix mosquitto_sub being unable to terminate with Ctrl-C if a successful
|
||||||
|
connection is not made. Closes #1957.
|
||||||
|
|
||||||
Apps:
|
Apps:
|
||||||
- Fix `mosquitto_passwd -b` using username as password (not if `-c` is also
|
- Fix `mosquitto_passwd -b` using username as password (not if `-c` is also
|
||||||
used). Closes #1949.
|
used). Closes #1949.
|
||||||
|
@ -45,13 +45,18 @@ struct mosquitto *mosq = NULL;
|
|||||||
int last_mid = 0;
|
int last_mid = 0;
|
||||||
static bool timed_out = false;
|
static bool timed_out = false;
|
||||||
static int connack_result = 0;
|
static int connack_result = 0;
|
||||||
|
bool connack_received = false;
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
void my_signal_handler(int signum)
|
void my_signal_handler(int signum)
|
||||||
{
|
{
|
||||||
if(signum == SIGALRM || signum == SIGTERM || signum == SIGINT){
|
if(signum == SIGALRM || signum == SIGTERM || signum == SIGINT){
|
||||||
process_messages = false;
|
if(connack_received){
|
||||||
mosquitto_disconnect_v5(mosq, MQTT_RC_DISCONNECT_WITH_WILL_MSG, cfg.disconnect_props);
|
process_messages = false;
|
||||||
|
mosquitto_disconnect_v5(mosq, MQTT_RC_DISCONNECT_WITH_WILL_MSG, cfg.disconnect_props);
|
||||||
|
}else{
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(signum == SIGALRM){
|
if(signum == SIGALRM){
|
||||||
timed_out = true;
|
timed_out = true;
|
||||||
@ -123,6 +128,8 @@ void my_connect_callback(struct mosquitto *mosq, void *obj, int result, int flag
|
|||||||
UNUSED(flags);
|
UNUSED(flags);
|
||||||
UNUSED(properties);
|
UNUSED(properties);
|
||||||
|
|
||||||
|
connack_received = true;
|
||||||
|
|
||||||
connack_result = result;
|
connack_result = result;
|
||||||
if(!result){
|
if(!result){
|
||||||
mosquitto_subscribe_multiple(mosq, NULL, cfg.topic_count, cfg.topics, cfg.qos, cfg.sub_opts, cfg.subscribe_props);
|
mosquitto_subscribe_multiple(mosq, NULL, cfg.topic_count, cfg.topics, cfg.qos, cfg.sub_opts, cfg.subscribe_props);
|
||||||
|
Loading…
Reference in New Issue
Block a user