~ubuntu-branches/debian/stretch/haproxy/stretch

« back to all changes in this revision

Viewing changes to include/proto/server.h

  • Committer: Package Import Robot
  • Author(s): Apollon Oikonomopoulos
  • Date: 2014-06-20 11:05:17 UTC
  • mfrom: (1.1.15) (15.1.12 experimental)
  • Revision ID: package-import@ubuntu.com-20140620110517-u6q5p9kyy2f3ozw9
Tags: 1.5.0-1
* New upstream stable series. Notable changes since the 1.4 series:
  + Native SSL support on both sides with SNI/NPN/ALPN and OCSP stapling.
  + IPv6 and UNIX sockets are supported everywhere
  + End-to-end HTTP keep-alive for better support of NTLM and improved
    efficiency in static farms
  + HTTP/1.1 response compression (deflate, gzip) to save bandwidth
  + PROXY protocol versions 1 and 2 on both sides
  + Data sampling on everything in request or response, including payload
  + ACLs can use any matching method with any input sample
  + Maps and dynamic ACLs updatable from the CLI
  + Stick-tables support counters to track activity on any input sample
  + Custom format for logs, unique-id, header rewriting, and redirects
  + Improved health checks (SSL, scripted TCP, check agent, ...)
  + Much more scalable configuration supports hundreds of thousands of
    backends and certificates without sweating

* Upload to unstable, merge all 1.5 work from experimental. Most important
  packaging changes since 1.4.25-1 include:
  + systemd support.
  + A more sane default config file.
  + Zero-downtime upgrades between 1.5 releases by gracefully reloading
    HAProxy during upgrades.
  + HTML documentation shipped in the haproxy-doc package.
  + kqueue support for kfreebsd.

* Packaging changes since 1.5~dev26-2:
  + Drop patches merged upstream:
    o Fix-reference-location-in-manpage.patch
    o 0001-BUILD-stats-workaround-stupid-and-bogus-Werror-forma.patch
  + d/watch: look for stable 1.5 releases
  + systemd: respect CONFIG and EXTRAOPTS when specified in
    /etc/default/haproxy.
  + initscript: test the configuration before start or reload.
  + initscript: remove the ENABLED flag and logic.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include <unistd.h>
26
26
 
27
27
#include <common/config.h>
 
28
#include <common/time.h>
28
29
#include <types/proxy.h>
29
30
#include <types/queue.h>
30
31
#include <types/server.h>
31
32
 
32
33
#include <proto/queue.h>
 
34
#include <proto/log.h>
33
35
#include <proto/freq_ctr.h>
34
36
 
35
 
int srv_downtime(struct server *s);
36
 
int srv_getinter(struct server *s);
 
37
int srv_downtime(const struct server *s);
 
38
int srv_lastsession(const struct server *s);
 
39
int srv_getinter(const struct check *check);
 
40
int parse_server(const char *file, int linenum, char **args, struct proxy *curproxy, struct proxy *defproxy);
37
41
 
38
42
/* increase the number of cumulated connections on the designated server */
39
43
static void inline srv_inc_sess_ctr(struct server *s)
44
48
                s->counters.sps_max = s->sess_per_sec.curr_ctr;
45
49
}
46
50
 
 
51
/* set the time of last session on the designated server */
 
52
static void inline srv_set_sess_last(struct server *s)
 
53
{
 
54
        s->counters.last_sess = now.tv_sec;
 
55
}
 
56
 
47
57
#endif /* _PROTO_SERVER_H */
48
58
 
 
59
/*
 
60
 * Registers the server keyword list <kwl> as a list of valid keywords for next
 
61
 * parsing sessions.
 
62
 */
 
63
void srv_register_keywords(struct srv_kw_list *kwl);
 
64
 
 
65
/* Return a pointer to the server keyword <kw>, or NULL if not found. */
 
66
struct srv_kw *srv_find_kw(const char *kw);
 
67
 
 
68
/* Dumps all registered "server" keywords to the <out> string pointer. */
 
69
void srv_dump_kws(char **out);
 
70
 
49
71
/* Recomputes the server's eweight based on its state, uweight, the current time,
50
72
 * and the proxy's algorihtm. To be used after updating sv->uweight. The warmup
51
73
 * state is automatically disabled if the time is elapsed.
67
89
}
68
90
 
69
91
/*
 
92
 * Parses weight_str and configures sv accordingly.
 
93
 * Returns NULL on success, error message string otherwise.
 
94
 */
 
95
const char *server_parse_weight_change_request(struct server *sv,
 
96
                                               const char *weight_str);
 
97
 
 
98
/*
 
99
 * Return true if the server has a zero user-weight, meaning it's in draining
 
100
 * mode (ie: not taking new non-persistent connections).
 
101
 */
 
102
static inline int server_is_draining(const struct server *s)
 
103
{
 
104
        return !s->uweight || (s->admin & SRV_ADMF_DRAIN);
 
105
}
 
106
 
 
107
/* Shutdown all connections of a server. The caller must pass a termination
 
108
 * code in <why>, which must be one of SN_ERR_* indicating the reason for the
 
109
 * shutdown.
 
110
 */
 
111
void srv_shutdown_sessions(struct server *srv, int why);
 
112
 
 
113
/* Shutdown all connections of all backup servers of a proxy. The caller must
 
114
 * pass a termination code in <why>, which must be one of SN_ERR_* indicating
 
115
 * the reason for the shutdown.
 
116
 */
 
117
void srv_shutdown_backup_sessions(struct proxy *px, int why);
 
118
 
 
119
/* Appends some information to a message string related to a server going UP or
 
120
 * DOWN.  If both <forced> and <reason> are null and the server tracks another
 
121
 * one, a "via" information will be provided to know where the status came from.
 
122
 * If <reason> is non-null, the entire string will be appended after a comma and
 
123
 * a space (eg: to report some information from the check that changed the state).
 
124
 * If <xferred> is non-negative, some information about requeued sessions are
 
125
 * provided.
 
126
 */
 
127
void srv_append_status(struct chunk *msg, struct server *s, const char *reason, int xferred, int forced);
 
128
 
 
129
/* Marks server <s> down, regardless of its checks' statuses, notifies by all
 
130
 * available means, recounts the remaining servers on the proxy and transfers
 
131
 * queued sessions whenever possible to other servers. It automatically
 
132
 * recomputes the number of servers, but not the map. Maintenance servers are
 
133
 * ignored. It reports <reason> if non-null as the reason for going down. Note
 
134
 * that it makes use of the trash to build the log strings, so <reason> must
 
135
 * not be placed there.
 
136
 */
 
137
void srv_set_stopped(struct server *s, const char *reason);
 
138
 
 
139
/* Marks server <s> up regardless of its checks' statuses and provided it isn't
 
140
 * in maintenance. Notifies by all available means, recounts the remaining
 
141
 * servers on the proxy and tries to grab requests from the proxy. It
 
142
 * automatically recomputes the number of servers, but not the map. Maintenance
 
143
 * servers are ignored. It reports <reason> if non-null as the reason for going
 
144
 * up. Note that it makes use of the trash to build the log strings, so <reason>
 
145
 * must not be placed there.
 
146
 */
 
147
void srv_set_running(struct server *s, const char *reason);
 
148
 
 
149
/* Marks server <s> stopping regardless of its checks' statuses and provided it
 
150
 * isn't in maintenance. Notifies by all available means, recounts the remaining
 
151
 * servers on the proxy and tries to grab requests from the proxy. It
 
152
 * automatically recomputes the number of servers, but not the map. Maintenance
 
153
 * servers are ignored. It reports <reason> if non-null as the reason for going
 
154
 * up. Note that it makes use of the trash to build the log strings, so <reason>
 
155
 * must not be placed there.
 
156
 */
 
157
void srv_set_stopping(struct server *s, const char *reason);
 
158
 
 
159
/* Enables admin flag <mode> (among SRV_ADMF_*) on server <s>. This is used to
 
160
 * enforce either maint mode or drain mode. It is not allowed to set more than
 
161
 * one flag at once. The equivalent "inherited" flag is propagated to all
 
162
 * tracking servers. Maintenance mode disables health checks (but not agent
 
163
 * checks). When either the flag is already set or no flag is passed, nothing
 
164
 * is done.
 
165
 */
 
166
void srv_set_admin_flag(struct server *s, enum srv_admin mode);
 
167
 
 
168
/* Disables admin flag <mode> (among SRV_ADMF_*) on server <s>. This is used to
 
169
 * stop enforcing either maint mode or drain mode. It is not allowed to set more
 
170
 * than one flag at once. The equivalent "inherited" flag is propagated to all
 
171
 * tracking servers. Leaving maintenance mode re-enables health checks. When
 
172
 * either the flag is already cleared or no flag is passed, nothing is done.
 
173
 */
 
174
void srv_clr_admin_flag(struct server *s, enum srv_admin mode);
 
175
 
 
176
/* Puts server <s> into maintenance mode, and propagate that status down to all
 
177
 * tracking servers.
 
178
 */
 
179
static inline void srv_adm_set_maint(struct server *s)
 
180
{
 
181
        srv_set_admin_flag(s, SRV_ADMF_FMAINT);
 
182
        srv_clr_admin_flag(s, SRV_ADMF_FDRAIN);
 
183
}
 
184
 
 
185
/* Puts server <s> into drain mode, and propagate that status down to all
 
186
 * tracking servers.
 
187
 */
 
188
static inline void srv_adm_set_drain(struct server *s)
 
189
{
 
190
        srv_set_admin_flag(s, SRV_ADMF_FDRAIN);
 
191
        srv_clr_admin_flag(s, SRV_ADMF_FMAINT);
 
192
}
 
193
 
 
194
/* Puts server <s> into ready mode, and propagate that status down to all
 
195
 * tracking servers.
 
196
 */
 
197
static inline void srv_adm_set_ready(struct server *s)
 
198
{
 
199
        srv_clr_admin_flag(s, SRV_ADMF_FDRAIN);
 
200
        srv_clr_admin_flag(s, SRV_ADMF_FMAINT);
 
201
}
 
202
 
 
203
/*
70
204
 * Local variables:
71
205
 *  c-indent-level: 8
72
206
 *  c-basic-offset: 8