]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: spoa-server: Allow registering external processes
authorThierry FOURNIER <thierry.fournier@ozon.io>
Fri, 23 Feb 2018 13:58:40 +0000 (14:58 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 13 May 2019 15:43:47 +0000 (17:43 +0200)
Add struct for declaring an reistrering external processing resource.

contrib/spoa_server/spoa.c
contrib/spoa_server/spoa.h

index 3766c47e6d44dedb56b5ece97664172172f81d23..6645c8ca3c061e7dc543ba31a62e4a3e8101d8bf 100644 (file)
@@ -97,6 +97,13 @@ static const char *spoe_frm_err_reasons[SPOE_FRM_ERRS] = {
 
 bool debug = false;
 pthread_key_t worker_id;
+static struct ps *ps_list = NULL;
+
+void ps_register(struct ps *ps)
+{
+       ps->next = ps_list;
+       ps_list = ps;
+}
 
 static void
 check_ipv4_reputation(struct worker *w, struct in_addr *ipv4)
@@ -925,10 +932,15 @@ spoa_worker(void *data)
        struct sockaddr_in client;
        int *info = (int *)data;
        int csock, lsock = info[0];
+       struct ps *ps;
 
        signal(SIGPIPE, SIG_IGN);
        pthread_setspecific(worker_id, &info[1]);
 
+       /* Init registered processors */
+       for (ps = ps_list; ps != NULL; ps = ps->next)
+               ps->init_worker(&w);
+
        while (1) {
                socklen_t sz = sizeof(client);
 
index 92c24ac55b205b588c02c8d6c309229eaa295de4..c8f9861b933a6460006b5f13e6f1654fff32fd2c 100644 (file)
@@ -80,9 +80,22 @@ struct spoe_data {
        union spoe_value    u;     /* spoe data value */
 };
 
+struct spoe_kv {
+       struct chunk name;
+       struct spoe_data value;
+};
+
+struct ps {
+       struct ps *next;
+       char *ext;
+       int (*init_worker)(struct worker *w);
+};
+
 extern bool debug;
 extern pthread_key_t worker_id;
 
+void ps_register(struct ps *ps);
+
 #define LOG(fmt, args...) \
        do { \
                struct timeval now; \