mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-18 09:24:31 +00:00
OPTIM: server: publish UP/DOWN events from STATE change
Reuse cb_data from STATE event to publish UP and DOWN events. This saves some CPU time since the event is only constructed once to publish STATE, STATE+UP or STATE+DOWN depending on the state change.
This commit is contained in:
parent
e3eea29f48
commit
c249f6d964
17
src/server.c
17
src/server.c
@ -5349,9 +5349,6 @@ static int _srv_update_status_op(struct server *s, enum srv_op_st_chg_cause caus
|
||||
*/
|
||||
xferred = pendconn_redistribute(s);
|
||||
|
||||
/* no maintenance + server DOWN: publish event SERVER DOWN */
|
||||
srv_event_hdl_publish(EVENT_HDL_SUB_SERVER_DOWN, s, 0);
|
||||
|
||||
tmptrash = alloc_trash_chunk();
|
||||
if (tmptrash) {
|
||||
chunk_printf(tmptrash,
|
||||
@ -5420,9 +5417,6 @@ static int _srv_update_status_op(struct server *s, enum srv_op_st_chg_cause caus
|
||||
*/
|
||||
xferred = pendconn_grab_from_px(s);
|
||||
|
||||
/* no maintenance + server going UP: publish event SERVER UP */
|
||||
srv_event_hdl_publish(EVENT_HDL_SUB_SERVER_UP, s, 0);
|
||||
|
||||
tmptrash = alloc_trash_chunk();
|
||||
if (tmptrash) {
|
||||
chunk_printf(tmptrash,
|
||||
@ -5504,9 +5498,6 @@ static int _srv_update_status_adm(struct server *s, enum srv_adm_st_chg_cause ca
|
||||
*/
|
||||
xferred = pendconn_redistribute(s);
|
||||
|
||||
/* maintenance on previously running server: publish event SERVER DOWN */
|
||||
srv_event_hdl_publish(EVENT_HDL_SUB_SERVER_DOWN, s, 0);
|
||||
|
||||
tmptrash = alloc_trash_chunk();
|
||||
if (tmptrash) {
|
||||
chunk_printf(tmptrash,
|
||||
@ -5565,12 +5556,6 @@ static int _srv_update_status_adm(struct server *s, enum srv_adm_st_chg_cause ca
|
||||
|
||||
}
|
||||
|
||||
/* ignore if server stays down when leaving maintenance mode */
|
||||
if (s->next_state != SRV_ST_STOPPED) {
|
||||
/* leaving maintenance + server UP: publish event SERVER UP */
|
||||
srv_event_hdl_publish(EVENT_HDL_SUB_SERVER_UP, s, 0);
|
||||
}
|
||||
|
||||
tmptrash = alloc_trash_chunk();
|
||||
if (tmptrash) {
|
||||
if (!(s->next_admin & SRV_ADMF_FMAINT) && (s->cur_admin & SRV_ADMF_FMAINT)) {
|
||||
@ -5814,10 +5799,12 @@ static void srv_update_status(struct server *s, int type, int cause)
|
||||
/* server was down and no longer is */
|
||||
if (s->last_change < ns_to_sec(now_ns)) // ignore negative times
|
||||
s->down_time += ns_to_sec(now_ns) - s->last_change;
|
||||
_srv_event_hdl_publish(EVENT_HDL_SUB_SERVER_UP, cb_data.common, s);
|
||||
}
|
||||
else if (s->cur_state == SRV_ST_STOPPED) {
|
||||
/* server was up and is currently down */
|
||||
s->counters.down_trans++;
|
||||
_srv_event_hdl_publish(EVENT_HDL_SUB_SERVER_DOWN, cb_data.common, s);
|
||||
}
|
||||
s->last_change = ns_to_sec(now_ns);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user