diff options
| author | Dusan Durech <dusan@debian.(none)> | 2008-11-11 23:39:21 +0100 |
|---|---|---|
| committer | Dusan Durech <dusan@debian.(none)> | 2008-11-11 23:39:21 +0100 |
| commit | 957f3411170ca1d5f30ee2e2c4e25393195cce75 (patch) | |
| tree | 18567d663d6d759d447b65458a410f426dae9044 /src/base/protect.c | |
| parent | de05256afe45ad24cda83ed1e2cf873c97de132c (diff) | |
modification coding stile :)
Diffstat (limited to 'src/base/protect.c')
| -rw-r--r-- | src/base/protect.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/base/protect.c b/src/base/protect.c index e06c618..9661e32 100644 --- a/src/base/protect.c +++ b/src/base/protect.c @@ -11,12 +11,14 @@ protect_t *newProtect() { protect_t *new; + new = malloc(sizeof(protect_t)); new->lastMove = getMyTime(); new->lastPing = getMyTime(); new->avarage = 0; new->count = 0; new->isDown = FALSE; + return new; } @@ -27,9 +29,11 @@ void refreshLastMove(protect_t * p) currentTime = getMyTime(); interval = currentTime - p->lastMove; + p->lastMove = getMyTime(); p->avarage += interval; p->count++; + if (p->count == PROTECT_SPEED_AVARAGE) { int index; @@ -62,8 +66,10 @@ bool_t isDown(protect_t * p) currentTime = getMyTime(); interval = currentTime - p->lastPing; + if (interval > PROTECT_PING_INTERVAL_TIMEOUT) p->isDown = TRUE; + return p->isDown; } |