X-Git-Url: https://git.realraum.at/?p=svn42.git;a=blobdiff_plain;f=door_daemon%2Fcommand_queue.c;h=0351f5c009cd0dd12331de01a1c6c18dba5a9753;hp=7ba22c70e794d9645b9e5baff225ef0589f90824;hb=4ee2501ff864b8e15202ee814e8bafcc0c2adf6c;hpb=5cdaab19f6a0c16cbce882a16c987c5c33f4190d diff --git a/door_daemon/command_queue.c b/door_daemon/command_queue.c index 7ba22c7..0351f5c 100644 --- a/door_daemon/command_queue.c +++ b/door_daemon/command_queue.c @@ -6,8 +6,9 @@ * This file is part of door_daemon. * * door_daemon is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 3 as - * published by the Free Software Foundation. + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. * * door_daemon is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -59,7 +60,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,18 +72,23 @@ int cmd_push(cmd_t** first, int fd, cmd_id_t cmd, const char* param) return 0; } -// timeout between 1 and 2 seconds -int cmd_has_expired(const cmd_t cmd) +void cmd_sent(cmd_t* cmd) +{ + if(!cmd) + return; + + cmd->sent = 1; + gettimeofday(&cmd->tv_start, NULL); +} + +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)