Fix timeout conversion error.
This commit is contained in:
parent
0097a85ce0
commit
2e72d795a9
@ -139,7 +139,7 @@ ifeq ($(UNAME),SunOS)
|
||||
CFLAGS?=-Wall -ggdb -O2
|
||||
endif
|
||||
else
|
||||
CFLAGS?=-Wall -ggdb -O2
|
||||
CFLAGS?=-Wall -ggdb -O2 -Wconversion
|
||||
endif
|
||||
|
||||
STATIC_LIB_DEPS:=
|
||||
|
20
lib/loop.c
20
lib/loop.c
@ -50,6 +50,7 @@ int mosquitto_loop(struct mosquitto *mosq, int timeout, int max_packets)
|
||||
#ifdef WITH_SRV
|
||||
int state;
|
||||
#endif
|
||||
time_t timeout_ms;
|
||||
|
||||
if(!mosq || max_packets < 1) return MOSQ_ERR_INVAL;
|
||||
#ifndef WIN32
|
||||
@ -109,26 +110,27 @@ int mosquitto_loop(struct mosquitto *mosq, int timeout, int max_packets)
|
||||
}
|
||||
}
|
||||
|
||||
if(timeout < 0){
|
||||
timeout = 1000;
|
||||
timeout_ms = timeout;
|
||||
if(timeout_ms < 0){
|
||||
timeout_ms = 1000;
|
||||
}
|
||||
|
||||
now = mosquitto_time();
|
||||
if(mosq->next_msg_out && now + timeout/1000 > mosq->next_msg_out){
|
||||
timeout = (mosq->next_msg_out - now)*1000;
|
||||
if(mosq->next_msg_out && now + timeout_ms/1000 > mosq->next_msg_out){
|
||||
timeout_ms = (mosq->next_msg_out - now)*1000;
|
||||
}
|
||||
|
||||
if(timeout < 0){
|
||||
if(timeout_ms < 0){
|
||||
/* There has been a delay somewhere which means we should have already
|
||||
* sent a message. */
|
||||
timeout = 0;
|
||||
timeout_ms = 0;
|
||||
}
|
||||
|
||||
local_timeout.tv_sec = timeout/1000;
|
||||
local_timeout.tv_sec = timeout_ms/1000;
|
||||
#ifdef HAVE_PSELECT
|
||||
local_timeout.tv_nsec = (timeout-local_timeout.tv_sec*1000)*1000000;
|
||||
local_timeout.tv_nsec = (timeout_ms-local_timeout.tv_sec*1000)*1000000;
|
||||
#else
|
||||
local_timeout.tv_usec = (timeout-local_timeout.tv_sec*1000)*1000;
|
||||
local_timeout.tv_usec = (timeout_ms-local_timeout.tv_sec*1000)*1000;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSELECT
|
||||
|
Loading…
Reference in New Issue
Block a user