Skip to content

Commit

Permalink
Remove unnecessary calls to time().
Browse files Browse the repository at this point in the history
  • Loading branch information
ralight committed Mar 13, 2019
1 parent 89f51aa commit 173b209
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/database.c
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@ int db__message_write(struct mosquitto_db *db, struct mosquitto *context)
const void *payload;
int msg_count = 0;
mosquitto_property *cmsg_props = NULL, *store_props = NULL;
time_t now;
time_t now = 0;
uint32_t expiry_interval = 0;

if(!context || context->sock == INVALID_SOCKET
Expand All @@ -922,11 +922,13 @@ int db__message_write(struct mosquitto_db *db, struct mosquitto *context)
return MOSQ_ERR_SUCCESS;
}

now = time(NULL);
tail = context->inflight_msgs;
while(tail){
msg_count++;
if(tail->store->message_expiry_time){
if(now == 0){
now = time(NULL);
}
if(now > tail->store->message_expiry_time){
/* Message is expired, must not send. */
db__message_remove(db, context, &tail, last);
Expand Down

0 comments on commit 173b209

Please sign in to comment.