MINOR: server/event_hdl: prepare for upcoming refactors
This commit does nothing that ought to be mentioned, except that
it adds missing comments and slighty moves some function calls
out of "sensitive" code in preparation of some server code refactors.
diff --git a/include/haproxy/server-t.h b/include/haproxy/server-t.h
index e7be7a3..d465fab 100644
--- a/include/haproxy/server-t.h
+++ b/include/haproxy/server-t.h
@@ -420,6 +420,8 @@
struct event_hdl_cb_data_server {
/* provided by:
* EVENT_HDL_SUB_SERVER_ADD
+ * EVENT_HDL_SUB_SERVER_DEL
+ * EVENT_HDL_SUB_SERVER_UP
* EVENT_HDL_SUB_SERVER_DOWN
*/
struct {
diff --git a/src/server.c b/src/server.c
index d17436c..bdb34c3 100644
--- a/src/server.c
+++ b/src/server.c
@@ -5301,9 +5301,6 @@
s->next_admin = s->cur_admin;
if ((s->cur_state != SRV_ST_STOPPED) && (s->next_state == SRV_ST_STOPPED)) {
- /* no maintenance + server DOWN: publish event SERVER DOWN */
- srv_event_hdl_publish(EVENT_HDL_SUB_SERVER_DOWN, s, 0);
-
s->last_change = now.tv_sec;
if (s->proxy->lbprm.set_server_status_down)
s->proxy->lbprm.set_server_status_down(s);
@@ -5317,6 +5314,9 @@
*/
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,
@@ -5371,9 +5371,6 @@
}
else if (((s->cur_state != SRV_ST_RUNNING) && (s->next_state == SRV_ST_RUNNING))
|| ((s->cur_state != SRV_ST_STARTING) && (s->next_state == SRV_ST_STARTING))) {
- /* no maintenance + server going UP: publish event SERVER UP */
- srv_event_hdl_publish(EVENT_HDL_SUB_SERVER_UP, s, 0);
-
if (s->proxy->srv_bck == 0 && s->proxy->srv_act == 0) {
if (s->proxy->last_change < now.tv_sec) // ignore negative times
s->proxy->down_time += now.tv_sec - s->proxy->last_change;
@@ -5414,6 +5411,9 @@
*/
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,
@@ -5500,9 +5500,6 @@
if (s->onmarkeddown & HANA_ONMARKEDDOWN_SHUTDOWNSESSIONS)
srv_shutdown_streams(s, SF_ERR_DOWN);
- /* maintenance on previously running server: publish event SERVER DOWN */
- srv_event_hdl_publish(EVENT_HDL_SUB_SERVER_DOWN, s, 0);
-
/* force connection cleanup on the given server */
srv_cleanup_connections(s);
/* we might have streams queued on this server and waiting for
@@ -5511,6 +5508,9 @@
*/
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,