Merge pull request #1514 from basavesh/fixes

In sub_client.c, call mosquitto_destroy() in cleanup label.
pull/1581/head
Roger Light 6 years ago committed by GitHub
commit 757e88e503
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -44,7 +44,7 @@ int last_mid = 0;
#ifndef WIN32
void my_signal_handler(int signum)
{
if(signum == SIGALRM){
if(signum == SIGALRM || signum == SIGTERM || signum == SIGINT){
process_messages = false;
mosquitto_disconnect_v5(mosq, MQTT_RC_DISCONNECT_WITH_WILL_MSG, cfg.disconnect_props);
}
@ -344,6 +344,16 @@ int main(int argc, char *argv[])
goto cleanup;
}
if(sigaction(SIGTERM, &sigact, NULL) == -1){
perror("sigaction");
goto cleanup;
}
if(sigaction(SIGINT, &sigact, NULL) == -1){
perror("sigaction");
goto cleanup;
}
if(cfg.timeout){
alarm(cfg.timeout);
}
@ -364,6 +374,7 @@ int main(int argc, char *argv[])
return rc;
cleanup:
mosquitto_destroy(mosq);
mosquitto_lib_cleanup();
client_config_cleanup(&cfg);
return 1;

Loading…
Cancel
Save