MINOR: server/event_hdl: add proxy_uuid to event_hdl_cb_data_server
authorAurelien DARRAGON <adarragon@haproxy.com>
Wed, 22 Mar 2023 16:35:47 +0000 (17:35 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 21 Apr 2023 12:36:45 +0000 (14:36 +0200)
Expose proxy_uuid variable in event_hdl_cb_data_server struct to
overcome proxy_name fixed length limitation.

proxy_uuid may be used by the handler to perform proxy lookups.
This should be preferred over lookups relying proxy_name.
(proxy_name is suitable for printing / logging purposes but not for
ID lookups since it has a maximum fixed length)

include/haproxy/server-t.h
src/server.c

index e7f7747..e7be7a3 100644 (file)
@@ -429,6 +429,7 @@ struct event_hdl_cb_data_server {
                 */
                char name[64];       /* server name/id */
                char proxy_name[64]; /* id of proxy the server belongs to */
+               int proxy_uuid;      /* uuid of the proxy the server belongs to */
                int puid;            /* proxy-unique server ID */
                uint32_t rid;        /* server id revision */
                unsigned int flags;  /* server flags */
index 1247537..d17436c 100644 (file)
@@ -151,8 +151,12 @@ static inline void srv_event_hdl_publish(struct event_hdl_sub_type event, struct
        cb_data.safe.rid = srv->rid;
        cb_data.safe.flags = srv->flags;
        snprintf(cb_data.safe.name, sizeof(cb_data.safe.name), "%s", srv->id);
-       if (srv->proxy)
+       cb_data.safe.proxy_name[0] = '\0';
+       cb_data.safe.proxy_uuid = -1; /* default value */
+       if (srv->proxy) {
+               cb_data.safe.proxy_uuid = srv->proxy->uuid;
                snprintf(cb_data.safe.proxy_name, sizeof(cb_data.safe.proxy_name), "%s", srv->proxy->id);
+       }
        /* unsafe data assignments */
        cb_data.unsafe.ptr = srv;
        cb_data.unsafe.thread_isolate = thread_isolate;