[636] Correctly handle empty files with "mosquitto_pub -l".

Thanks to Aleksandr Makarov.

Bug: https://github.com/eclipse/mosquitto/issues/676
pull/712/merge
Roger A. Light 8 years ago
parent 7d8d04bc39
commit 15486f48e7

@ -23,6 +23,9 @@ Client library:
- Fix mosquitto_topic_matches_sub() not correctly matching foo/bar against
foo/+/#. Closes #670.
Clients:
- Correctly handle empty files with "mosquitto_pub -l". Closes #676.
Build:
- Don't run TLS-PSK tests if TLS-PSK disabled at compile time. Closes #636.

@ -34,6 +34,7 @@ Contributors:
#define STATUS_CONNECTING 0
#define STATUS_CONNACK_RECVD 1
#define STATUS_WAITING 2
#define STATUS_DISCONNECTING 3
/* Global variables for use in callbacks. See sub_client.c for an example of
* using a struct to hold variables for use in callbacks. */
@ -410,8 +411,15 @@ int main(int argc, char *argv[])
}
}
if(feof(stdin)){
last_mid = mid_sent;
status = STATUS_WAITING;
if(last_mid == -1){
/* Empty file */
mosquitto_disconnect(mosq);
disconnect_sent = true;
status = STATUS_DISCONNECTING;
}else{
last_mid = mid_sent;
status = STATUS_WAITING;
}
}
}else if(status == STATUS_WAITING){
if(last_mid_sent == last_mid && disconnect_sent == false){

Loading…
Cancel
Save