blob: 0016c802890b6c7984acaab5ac229ecebba3a109 [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 Tarreauec6c5df2008-07-15 00:22:45 +020017#include <proto/server.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020018
Krzysztof Oledzki85130942007-10-22 16:21:10 +020019int 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 Tarreaubaaee002006-06-26 02:48:02 +020026
Krzysztof Piotr Oledzki5259dfe2008-01-21 01:54:06 +010027int 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 Tarreaubaaee002006-06-26 02:48:02 +020039/*
40 * Local variables:
41 * c-indent-level: 8
42 * c-basic-offset: 8
43 * End:
44 */