blob: bf29d2537d00905d9de696f3411d83fb5269e1f8 [file] [log] [blame]
Willy Tarreaubaaee002006-06-26 02:48:02 +02001/*
2 * Server management functions.
3 *
4 * Copyright 2000-2006 Willy Tarreau <w@1wt.eu>
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +01005 * Copyright 2007-2008 Krzysztof Piotr Oledzki <ole@ans.pl>
Willy Tarreaubaaee002006-06-26 02:48:02 +02006 *
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 Tarreaue3ba5f02006-06-29 18:54:54 +020014#include <common/config.h>
Krzysztof Oledzki85130942007-10-22 16:21:10 +020015#include <common/time.h>
16
Willy Tarreaubaaee002006-06-26 02:48:02 +020017#include <types/backend.h>
18#include <types/proxy.h>
19#include <types/server.h>
20
Krzysztof Oledzki85130942007-10-22 16:21:10 +020021int 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 Tarreaubaaee002006-06-26 02:48:02 +020028
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +010029int 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 Tarreaubaaee002006-06-26 02:48:02 +020041/*
42 * Local variables:
43 * c-indent-level: 8
44 * c-basic-offset: 8
45 * End:
46 */