mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-27 23:22:09 +00:00
MINOR: proxy/listener: support for additional PAUSED state
This patch is a prerequisite for #1626. Adding PAUSED state to the list of available proxy states. The flag is set when the proxy is paused at runtime (pause_listener()). It is cleared when the proxy is resumed (resume_listener()). It should be backported to 2.6, 2.5 and 2.4
This commit is contained in:
parent
001328873c
commit
d46f437de6
@ -211,6 +211,7 @@ enum PR_SRV_STATE_FILE {
|
||||
#define PR_FL_READY 0x04 /* The proxy is ready to be used (initialized and configured) */
|
||||
#define PR_FL_EXPLICIT_REF 0x08 /* The default proxy is explicitly referenced by another proxy */
|
||||
#define PR_FL_IMPLICIT_REF 0x10 /* The default proxy is implicitly referenced by another proxy */
|
||||
#define PR_FL_PAUSED 0x20 /* The proxy was paused at run time (reversible) */
|
||||
|
||||
struct stream;
|
||||
|
||||
|
@ -40,6 +40,8 @@ extern const struct cfg_opt cfg_opts[];
|
||||
extern const struct cfg_opt cfg_opts2[];
|
||||
|
||||
struct task *manage_proxy(struct task *t, void *context, unsigned int state);
|
||||
void proxy_cond_pause(struct proxy *p);
|
||||
void proxy_cond_resume(struct proxy *p);
|
||||
void proxy_cond_disable(struct proxy *p);
|
||||
void soft_stop(void);
|
||||
int pause_proxy(struct proxy *p);
|
||||
|
@ -481,6 +481,8 @@ int pause_listener(struct listener *l, int lpx)
|
||||
listener_set_state(l, LI_PAUSED);
|
||||
|
||||
if (px && !px->li_ready) {
|
||||
/* PROXY_LOCK is required */
|
||||
proxy_cond_pause(px);
|
||||
ha_warning("Paused %s %s.\n", proxy_cap_str(px->cap), px->id);
|
||||
send_log(px, LOG_WARNING, "Paused %s %s.\n", proxy_cap_str(px->cap), px->id);
|
||||
}
|
||||
@ -540,6 +542,8 @@ int resume_listener(struct listener *l, int lpx)
|
||||
|
||||
done:
|
||||
if (was_paused && !px->li_paused) {
|
||||
/* PROXY_LOCK is required */
|
||||
proxy_cond_resume(px);
|
||||
ha_warning("Resumed %s %s.\n", proxy_cap_str(px->cap), px->id);
|
||||
send_log(px, LOG_WARNING, "Resumed %s %s.\n", proxy_cap_str(px->cap), px->id);
|
||||
}
|
||||
|
20
src/proxy.c
20
src/proxy.c
@ -1915,6 +1915,26 @@ struct proxy *parse_new_proxy(const char *name, unsigned int cap,
|
||||
return curproxy;
|
||||
}
|
||||
|
||||
/* to be called under the proxy lock after pausing some listeners. This will
|
||||
* automatically update the p->flags flag
|
||||
*/
|
||||
void proxy_cond_pause(struct proxy *p)
|
||||
{
|
||||
if (p->li_ready)
|
||||
return;
|
||||
p->flags |= PR_FL_PAUSED;
|
||||
}
|
||||
|
||||
/* to be called under the proxy lock after resuming some listeners. This will
|
||||
* automatically update the p->flags flag
|
||||
*/
|
||||
void proxy_cond_resume(struct proxy *p)
|
||||
{
|
||||
if (!p->li_ready)
|
||||
return;
|
||||
p->flags &= ~PR_FL_PAUSED;
|
||||
}
|
||||
|
||||
/* to be called under the proxy lock after stopping some listeners. This will
|
||||
* automatically update the p->flags flag after stopping the last one, and
|
||||
* will emit a log indicating the proxy's condition. The function is idempotent
|
||||
|
Loading…
Reference in New Issue
Block a user