summaryrefslogtreecommitdiff
path: root/src/timer.c
diff options
context:
space:
mode:
authorfourdan2007-01-29 10:09:59 +0000
committerfourdan2007-01-29 10:09:59 +0000
commit68e3c0ed570ba3e994f8a1c4b20594372fb0b514 (patch)
tree8d6c0d6876340742ea6f49dc9faa40aef9855563 /src/timer.c
parent6fc08ea508e4fa39a9bf7f5495e84a68bd0bf88a (diff)
parentf70181ffe0b37952384ff5e0ce0185541828014f (diff)
downloadivy-c-68e3c0ed570ba3e994f8a1c4b20594372fb0b514.zip
ivy-c-68e3c0ed570ba3e994f8a1c4b20594372fb0b514.tar.gz
ivy-c-68e3c0ed570ba3e994f8a1c4b20594372fb0b514.tar.bz2
ivy-c-68e3c0ed570ba3e994f8a1c4b20594372fb0b514.tar.xz
Rename protocol_v3 as trunk to avoid confusion on protocol version to use.
Diffstat (limited to 'src/timer.c')
-rw-r--r--src/timer.c35
1 files changed, 16 insertions, 19 deletions
diff --git a/src/timer.c b/src/timer.c
index 7efb3ce..4e38c52 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -6,7 +6,7 @@
*
* Timers used in select based main loop
*
- * Authors: François-Régis Colin <fcolin@cena.fr>
+ * Authors: François-Régis Colin <fcolin@cena.dgac.fr>
*
* $Id$
*
@@ -15,20 +15,16 @@
*/
/* Module de gestion des timers autour d'un select */
-
#include <stdio.h>
#include <sys/types.h>
#include <time.h>
#include <stdlib.h>
#include <memory.h>
-
#ifdef WIN32
-#include <crtdbg.h>
#include <windows.h>
#else
#include <sys/time.h>
#endif
-
#include "list.h"
#include "timer.h"
@@ -107,18 +103,16 @@ TimerId TimerRepeatAfter( int count, long time, TimerCb cb, void *user_data )
/* si y a rien a faire et ben on fait rien */
if ( cb == NULL ) return NULL;
- IVY_LIST_ADD( timers, timer )
- if ( timer )
- {
- timer->repeat = count;
- timer->callback = cb;
- timer->user_data = user_data;
- stamp = currentTime();
- timer->period = time;
- timer->when = stamp + time;
- if ( (timer->when < nextTimeout) || (timeoutptr == NULL))
- SetNewTimeout( stamp, timer->when );
- }
+ IVY_LIST_ADD_START( timers, timer )
+ timer->repeat = count;
+ timer->callback = cb;
+ timer->user_data = user_data;
+ stamp = currentTime();
+ timer->period = time;
+ timer->when = stamp + time;
+ if ( (timer->when < nextTimeout) || (timeoutptr == NULL))
+ SetNewTimeout( stamp, timer->when );
+ IVY_LIST_ADD_END( timers, timer )
return timer;
}
void TimerRemove( TimerId timer )
@@ -143,6 +137,10 @@ void TimerModify( TimerId timer, long time )
struct timeval *TimerGetSmallestTimeout()
{
+ unsigned long stamp;
+ /* recalcul du prochain timeout */
+ stamp = currentTime();
+ AdjTimeout( stamp );
return timeoutptr;
}
@@ -174,6 +172,5 @@ void TimerScan()
}
}
}
- /* recalcul du prochain timeout */
- AdjTimeout( stamp );
+
}