Commits

Roger Light  committed eedb066

Fix possibility of mosquitto_pub not exiting after sending messages when
using -l.

  • Participants
  • Parent commits c8d9b22
  • Branches 1.3.1

Comments (0)

Files changed (2)

File ChangeLog.txt

 
 Clients:
 - Fix keepalive value on mosquitto_pub.
+- Fix possibility of mosquitto_pub not exiting after sending messages when
+  using -l.
 
 1.3 - 20140316
 ==============

File client/pub_client.c

 /*
-Copyright (c) 2009-2013 Roger Light <roger@atchoo.org>
+Copyright (c) 2009-2014 Roger Light <roger@atchoo.org>
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 static int status = STATUS_CONNECTING;
 static int mid_sent = 0;
 static int last_mid = -1;
+static int last_mid_sent = -1;
 static bool connected = true;
 static char *username = NULL;
 static char *password = NULL;
 
 void my_publish_callback(struct mosquitto *mosq, void *obj, int mid)
 {
+	last_mid_sent = mid;
 	if(mode == MSGMODE_STDIN_LINE){
 		if(mid == last_mid){
 			mosquitto_disconnect(mosq);
 					status = STATUS_WAITING;
 				}
 			}else if(status == STATUS_WAITING){
+				if(last_mid_sent == last_mid && disconnect_sent == false){
+					mosquitto_disconnect(mosq);
+					disconnect_sent = true;
+				}
 #ifdef WIN32
-				Sleep(1000);
+				Sleep(100);
 #else
-				usleep(1000000);
+				usleep(100000);
 #endif
 			}
 			rc = MOSQ_ERR_SUCCESS;