Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 1 | /* |
| 2 | include/types/server.h |
| 3 | This file defines everything related to servers. |
| 4 | |
| 5 | Copyright (C) 2000-2006 Willy Tarreau - w@1wt.eu |
| 6 | |
| 7 | This library is free software; you can redistribute it and/or |
| 8 | modify it under the terms of the GNU Lesser General Public |
| 9 | License as published by the Free Software Foundation, version 2.1 |
| 10 | exclusively. |
| 11 | |
| 12 | This library is distributed in the hope that it will be useful, |
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | Lesser General Public License for more details. |
| 16 | |
| 17 | You should have received a copy of the GNU Lesser General Public |
| 18 | License along with this library; if not, write to the Free Software |
| 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | */ |
| 21 | |
| 22 | #ifndef _TYPES_SERVER_H |
| 23 | #define _TYPES_SERVER_H |
| 24 | |
| 25 | #include <netinet/in.h> |
| 26 | #include <arpa/inet.h> |
| 27 | |
Willy Tarreau | e3ba5f0 | 2006-06-29 18:54:54 +0200 | [diff] [blame] | 28 | #include <common/config.h> |
Willy Tarreau | 2dd0d47 | 2006-06-29 17:53:05 +0200 | [diff] [blame] | 29 | #include <common/mini-clist.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 30 | |
| 31 | #include <types/buffers.h> |
| 32 | #include <types/proxy.h> |
| 33 | #include <types/queue.h> |
| 34 | #include <types/task.h> |
| 35 | |
| 36 | |
| 37 | /* server flags */ |
| 38 | #define SRV_RUNNING 1 /* the server is UP */ |
| 39 | #define SRV_BACKUP 2 /* this server is a backup server */ |
| 40 | #define SRV_MAPPORTS 4 /* this server uses mapped ports */ |
| 41 | #define SRV_BIND_SRC 8 /* this server uses a specific source address */ |
| 42 | #define SRV_CHECKED 16 /* this server needs to be checked */ |
| 43 | |
| 44 | /* function which act on servers need to return various errors */ |
| 45 | #define SRV_STATUS_OK 0 /* everything is OK. */ |
| 46 | #define SRV_STATUS_INTERNAL 1 /* other unrecoverable errors. */ |
| 47 | #define SRV_STATUS_NOSRV 2 /* no server is available */ |
| 48 | #define SRV_STATUS_FULL 3 /* the/all server(s) are saturated */ |
| 49 | #define SRV_STATUS_QUEUED 4 /* the/all server(s) are saturated but the connection was queued */ |
| 50 | |
| 51 | |
| 52 | struct server { |
| 53 | struct server *next; |
| 54 | int state; /* server state (SRV_*) */ |
| 55 | int cklen; /* the len of the cookie, to speed up checks */ |
| 56 | char *cookie; /* the id set in the cookie */ |
| 57 | char *id; /* just for identification */ |
| 58 | struct list pendconns; /* pending connections */ |
| 59 | int nbpend, nbpend_max; /* number of pending connections */ |
| 60 | struct task *queue_mgt; /* the task associated to the queue processing */ |
| 61 | struct sockaddr_in addr; /* the address to connect to */ |
| 62 | struct sockaddr_in source_addr; /* the address to which we want to bind for connect() */ |
| 63 | short check_port; /* the port to use for the health checks */ |
| 64 | int health; /* 0->rise-1 = bad; rise->rise+fall-1 = good */ |
| 65 | int rise, fall; /* time in iterations */ |
| 66 | int inter; /* time in milliseconds */ |
| 67 | int result; /* 0 = connect OK, -1 = connect KO */ |
| 68 | int curfd; /* file desc used for current test, or -1 if not in test */ |
| 69 | unsigned char uweight, eweight; /* user-specified weight-1, and effective weight-1 */ |
| 70 | unsigned int wscore; /* weight score, used during srv map computation */ |
| 71 | int cur_sess, cur_sess_max; /* number of currently active sessions (including syn_sent) */ |
| 72 | unsigned int cum_sess; /* cumulated number of sessions really sent to this server */ |
| 73 | unsigned int maxconn, minconn; /* max # of active sessions (0 = unlimited), min# for dynamic limit. */ |
| 74 | unsigned failed_checks, down_trans; /* failed checks and up-down transitions */ |
| 75 | unsigned failed_conns, failed_resp; /* failed connect() and responses */ |
| 76 | unsigned failed_secu; /* blocked responses because of security concerns */ |
| 77 | struct proxy *proxy; /* the proxy this server belongs to */ |
| 78 | }; |
| 79 | |
| 80 | |
| 81 | #endif /* _TYPES_SERVER_H */ |
| 82 | |
| 83 | /* |
| 84 | * Local variables: |
| 85 | * c-indent-level: 8 |
| 86 | * c-basic-offset: 8 |
| 87 | * End: |
| 88 | */ |