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 | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 17 | #include <types/backend.h> |
| 18 | #include <types/proxy.h> |
| 19 | #include <types/server.h> |
| 20 | |
Krzysztof Oledzki | 8513094 | 2007-10-22 16:21:10 +0200 | [diff] [blame] | 21 | int srv_downtime(struct server *s) { |
| 22 | |
| 23 | if ((s->state & SRV_RUNNING) && s->last_change < now.tv_sec) // ignore negative time |
| 24 | return s->down_time; |
| 25 | |
| 26 | return now.tv_sec - s->last_change + s->down_time; |
| 27 | } |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 28 | |
Krzysztof Piotr Oledzki | 5259dfe | 2008-01-21 01:54:06 +0100 | [diff] [blame] | 29 | int srv_getinter(struct server *s) { |
| 30 | |
| 31 | if ((s->state & SRV_CHECKED) && (s->health == s->rise + s->fall - 1)) |
| 32 | return s->inter; |
| 33 | |
| 34 | if (!(s->state & SRV_RUNNING) && s->health==0) |
| 35 | return (s->downinter)?(s->downinter):(s->inter); |
| 36 | |
| 37 | return (s->fastinter)?(s->fastinter):(s->inter); |
| 38 | } |
| 39 | |
| 40 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 41 | /* |
| 42 | * Local variables: |
| 43 | * c-indent-level: 8 |
| 44 | * c-basic-offset: 8 |
| 45 | * End: |
| 46 | */ |