Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Server management functions. |
| 3 | * |
| 4 | * Copyright 2000-2006 Willy Tarreau <w@1wt.eu> |
Krzysztof Piotr Oledzki | 5259dfe | 2008-01-21 01:54:06 +0100 | [diff] [blame] | 5 | * Copyright 2007-2008 Krzysztof Piotr Oledzki <ole@ans.pl> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License |
| 9 | * as published by the Free Software Foundation; either version |
| 10 | * 2 of the License, or (at your option) any later version. |
| 11 | * |
| 12 | */ |
| 13 | |
Willy Tarreau | e3ba5f0 | 2006-06-29 18:54:54 +0200 | [diff] [blame] | 14 | #include <common/config.h> |
Krzysztof Oledzki | 8513094 | 2007-10-22 16:21:10 +0200 | [diff] [blame] | 15 | #include <common/time.h> |
| 16 | |
Willy Tarreau | ec6c5df | 2008-07-15 00:22:45 +0200 | [diff] [blame] | 17 | #include <proto/server.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 18 | |
Krzysztof Oledzki | 8513094 | 2007-10-22 16:21:10 +0200 | [diff] [blame] | 19 | int srv_downtime(struct server *s) { |
| 20 | |
| 21 | if ((s->state & SRV_RUNNING) && s->last_change < now.tv_sec) // ignore negative time |
| 22 | return s->down_time; |
| 23 | |
| 24 | return now.tv_sec - s->last_change + s->down_time; |
| 25 | } |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 26 | |
Krzysztof Piotr Oledzki | 5259dfe | 2008-01-21 01:54:06 +0100 | [diff] [blame] | 27 | int srv_getinter(struct server *s) { |
| 28 | |
| 29 | if ((s->state & SRV_CHECKED) && (s->health == s->rise + s->fall - 1)) |
| 30 | return s->inter; |
| 31 | |
| 32 | if (!(s->state & SRV_RUNNING) && s->health==0) |
| 33 | return (s->downinter)?(s->downinter):(s->inter); |
| 34 | |
| 35 | return (s->fastinter)?(s->fastinter):(s->inter); |
| 36 | } |
| 37 | |
| 38 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 39 | /* |
| 40 | * Local variables: |
| 41 | * c-indent-level: 8 |
| 42 | * c-basic-offset: 8 |
| 43 | * End: |
| 44 | */ |