From: realraum Date: Thu, 4 Jun 2009 23:16:51 +0000 (+0000) Subject: fixed command timeout X-Git-Url: https://git.realraum.at/?a=commitdiff_plain;h=336ec431afa20c95a936a210785b25bfdf6efb9e;p=svn42.git fixed command timeout --- diff --git a/door_daemon/command_queue.c b/door_daemon/command_queue.c index 3fc645a..8e6ca2c 100644 --- a/door_daemon/command_queue.c +++ b/door_daemon/command_queue.c @@ -80,18 +80,14 @@ void cmd_sent(cmd_t* cmd) gettimeofday(&cmd->tv_start, NULL); } -// timeout between 1 and 2 seconds -int cmd_has_expired(const cmd_t cmd) +int cmd_has_expired(cmd_t cmd) { struct timeval now; - now.tv_sec = 2; - now.tv_usec = 0; + timerclear(&now); gettimeofday(&now, NULL); - - if(cmd.tv_start.tv_sec + 2 >= now.tv_sec) - return 1; - - return 0; + cmd.tv_start.tv_sec++; + + return timercmp(&cmd.tv_start, &now, <); } void cmd_pop(cmd_t** first) diff --git a/door_daemon/command_queue.h b/door_daemon/command_queue.h index 2397fb7..bc153fe 100644 --- a/door_daemon/command_queue.h +++ b/door_daemon/command_queue.h @@ -38,7 +38,7 @@ typedef struct cmd_struct cmd_t; int cmd_push(cmd_t** first, int fd, cmd_id_t cmd, const char* param); void cmd_sent(cmd_t* cmd); -int cmd_has_expired(const cmd_t cmd); +int cmd_has_expired(cmd_t cmd); void cmd_pop(cmd_t** first); void cmd_clear(cmd_t** first);