projects
/
svn42.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
added timeout for commands
[svn42.git]
/
door_daemon
/
command_queue.c
diff --git
a/door_daemon/command_queue.c
b/door_daemon/command_queue.c
index
638c08b
..
7ba22c7
100644
(file)
--- a/
door_daemon/command_queue.c
+++ b/
door_daemon/command_queue.c
@@
-57,6
+57,9
@@
int cmd_push(cmd_t** first, int fd, cmd_id_t cmd, const char* param)
else
new_cmd->param = NULL;
new_cmd->sent = 0;
else
new_cmd->param = NULL;
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)) {
new_cmd->next = NULL;
if(!(*first)) {
@@
-69,6
+72,20
@@
int cmd_push(cmd_t** first, int fd, cmd_id_t cmd, const char* param)
return 0;
}
return 0;
}
+// timeout between 1 and 2 seconds
+int cmd_has_expired(const cmd_t cmd)
+{
+ struct timeval now;
+ now.tv_sec = 2;
+ now.tv_usec = 0;
+ gettimeofday(&now, NULL);
+
+ if(cmd.tv_start.tv_sec + 2 >= now.tv_sec)
+ return 1;
+
+ return 0;
+}
+
void cmd_pop(cmd_t** first)
{
if(!first || !(*first))
void cmd_pop(cmd_t** first)
{
if(!first || !(*first))