From: Christian Pointner Date: Thu, 4 Jun 2009 22:50:17 +0000 (+0000) Subject: fixed command timout X-Git-Url: https://git.realraum.at/?a=commitdiff_plain;h=85321f6407b6e8febc4af9f672a6346413610cd0;p=svn42.git fixed command timout --- diff --git a/door_daemon/command_queue.c b/door_daemon/command_queue.c index 7ba22c7..3fc645a 100644 --- a/door_daemon/command_queue.c +++ b/door_daemon/command_queue.c @@ -59,7 +59,6 @@ int cmd_push(cmd_t** first, int fd, cmd_id_t cmd, const char* param) new_cmd->sent = 0; new_cmd->tv_start.tv_sec = 0; new_cmd->tv_start.tv_usec = 0; - gettimeofday(&new_cmd->tv_start, NULL); new_cmd->next = NULL; if(!(*first)) { @@ -72,6 +71,15 @@ int cmd_push(cmd_t** first, int fd, cmd_id_t cmd, const char* param) return 0; } +void cmd_sent(cmd_t* cmd) +{ + if(!cmd) + return; + + cmd->sent = 1; + gettimeofday(&cmd->tv_start, NULL); +} + // timeout between 1 and 2 seconds int cmd_has_expired(const cmd_t cmd) { diff --git a/door_daemon/command_queue.h b/door_daemon/command_queue.h index d03602f..2397fb7 100644 --- a/door_daemon/command_queue.h +++ b/door_daemon/command_queue.h @@ -37,6 +37,7 @@ struct cmd_struct { 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); void cmd_pop(cmd_t** first); void cmd_clear(cmd_t** first); diff --git a/door_daemon/door_daemon.c b/door_daemon/door_daemon.c index 0443910..da6b3a2 100644 --- a/door_daemon/door_daemon.c +++ b/door_daemon/door_daemon.c @@ -95,7 +95,7 @@ int send_command(int door_fd, cmd_t* cmd) } while(!ret || (ret == -1 && errno == EINTR)); if(ret > 0) { - cmd->sent = 1; + cmd_sent(cmd); return 0; }