MINOR: spoa-server: Allow registering external processes

Add struct for declaring an reistrering external processing resource.
This commit is contained in:
Thierry FOURNIER 2018-02-23 14:58:40 +01:00 committed by Willy Tarreau
parent 786e9e684b
commit 64eaa33214
2 changed files with 25 additions and 0 deletions

View 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);

View 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; \