X-Git-Url: https://git.realraum.at/?a=blobdiff_plain;f=door_daemon%2Fcommand_queue.c;h=0351f5c009cd0dd12331de01a1c6c18dba5a9753;hb=ff9137d257207a3a4b03c4f453cc1b7ce1e3cf17;hp=638c08b6913c4a356d5dfc76c9ab6f29fc13b243;hpb=8fe111b5262925abdaf1614627ecfd128e112b11;p=svn42.git diff --git a/door_daemon/command_queue.c b/door_daemon/command_queue.c index 638c08b..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 @@ -57,6 +58,8 @@ int cmd_push(cmd_t** first, int fd, cmd_id_t cmd, const char* param) else new_cmd->param = NULL; new_cmd->sent = 0; + new_cmd->tv_start.tv_sec = 0; + new_cmd->tv_start.tv_usec = 0; new_cmd->next = NULL; if(!(*first)) { @@ -69,6 +72,25 @@ 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); +} + +int cmd_has_expired(cmd_t cmd) +{ + struct timeval now; + timerclear(&now); + gettimeofday(&now, NULL); + cmd.tv_start.tv_sec++; + + return timercmp(&cmd.tv_start, &now, <); +} + void cmd_pop(cmd_t** first) { if(!first || !(*first))