44
48
s->counters.sps_max = s->sess_per_sec.curr_ctr;
51
/* set the time of last session on the designated server */
52
static void inline srv_set_sess_last(struct server *s)
54
s->counters.last_sess = now.tv_sec;
47
57
#endif /* _PROTO_SERVER_H */
60
* Registers the server keyword list <kwl> as a list of valid keywords for next
63
void srv_register_keywords(struct srv_kw_list *kwl);
65
/* Return a pointer to the server keyword <kw>, or NULL if not found. */
66
struct srv_kw *srv_find_kw(const char *kw);
68
/* Dumps all registered "server" keywords to the <out> string pointer. */
69
void srv_dump_kws(char **out);
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.
92
* Parses weight_str and configures sv accordingly.
93
* Returns NULL on success, error message string otherwise.
95
const char *server_parse_weight_change_request(struct server *sv,
96
const char *weight_str);
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).
102
static inline int server_is_draining(const struct server *s)
104
return !s->uweight || (s->admin & SRV_ADMF_DRAIN);
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
111
void srv_shutdown_sessions(struct server *srv, int why);
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.
117
void srv_shutdown_backup_sessions(struct proxy *px, int why);
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
127
void srv_append_status(struct chunk *msg, struct server *s, const char *reason, int xferred, int forced);
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.
137
void srv_set_stopped(struct server *s, const char *reason);
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.
147
void srv_set_running(struct server *s, const char *reason);
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.
157
void srv_set_stopping(struct server *s, const char *reason);
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
166
void srv_set_admin_flag(struct server *s, enum srv_admin mode);
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.
174
void srv_clr_admin_flag(struct server *s, enum srv_admin mode);
176
/* Puts server <s> into maintenance mode, and propagate that status down to all
179
static inline void srv_adm_set_maint(struct server *s)
181
srv_set_admin_flag(s, SRV_ADMF_FMAINT);
182
srv_clr_admin_flag(s, SRV_ADMF_FDRAIN);
185
/* Puts server <s> into drain mode, and propagate that status down to all
188
static inline void srv_adm_set_drain(struct server *s)
190
srv_set_admin_flag(s, SRV_ADMF_FDRAIN);
191
srv_clr_admin_flag(s, SRV_ADMF_FMAINT);
194
/* Puts server <s> into ready mode, and propagate that status down to all
197
static inline void srv_adm_set_ready(struct server *s)
199
srv_clr_admin_flag(s, SRV_ADMF_FDRAIN);
200
srv_clr_admin_flag(s, SRV_ADMF_FMAINT);
70
204
* Local variables:
71
205
* c-indent-level: 8
72
206
* c-basic-offset: 8