moved raspberry and router gpio to pi_as_powerwitch on github
[svn42.git] / door_daemon / command_queue.c
index 3fc645a..0351f5c 100644 (file)
@@ -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
@@ -80,18 +81,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)