mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-28 23:52:06 +00:00
MINOR: spoa-server: Allow registering message processors
This function register processor executed by any language for processing an SPOP message.
This commit is contained in:
parent
64eaa33214
commit
892f6647c1
@ -98,6 +98,7 @@ static const char *spoe_frm_err_reasons[SPOE_FRM_ERRS] = {
|
||||
bool debug = false;
|
||||
pthread_key_t worker_id;
|
||||
static struct ps *ps_list = NULL;
|
||||
static struct ps_message *ps_messages = NULL;
|
||||
|
||||
void ps_register(struct ps *ps)
|
||||
{
|
||||
@ -105,6 +106,35 @@ void ps_register(struct ps *ps)
|
||||
ps_list = ps;
|
||||
}
|
||||
|
||||
void ps_register_message(struct ps *ps, const char *name, void *ref)
|
||||
{
|
||||
struct ps_message *msg;
|
||||
|
||||
/* Look for already registered name */
|
||||
for (msg = ps_messages; msg; msg = msg->next) {
|
||||
if (strcmp(name, msg->name) == 0) {
|
||||
LOG("Message \"%s\" already registered\n", name);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
msg = calloc(1, sizeof(*msg));
|
||||
if (msg == NULL) {
|
||||
LOG("Out of memory error\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
msg->next = ps_messages;
|
||||
ps_messages = msg;
|
||||
msg->name = strdup(name);
|
||||
if (msg->name == NULL) {
|
||||
LOG("Out of memory error\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
msg->ref = ref;
|
||||
msg->ps = ps;
|
||||
}
|
||||
|
||||
static void
|
||||
check_ipv4_reputation(struct worker *w, struct in_addr *ipv4)
|
||||
{
|
||||
|
@ -89,12 +89,21 @@ struct ps {
|
||||
struct ps *next;
|
||||
char *ext;
|
||||
int (*init_worker)(struct worker *w);
|
||||
int (*exec_message)(struct worker *w, void *ref, int nargs, struct spoe_kv *args);
|
||||
};
|
||||
|
||||
struct ps_message {
|
||||
struct ps_message *next;
|
||||
const char *name;
|
||||
struct ps *ps;
|
||||
void *ref;
|
||||
};
|
||||
|
||||
extern bool debug;
|
||||
extern pthread_key_t worker_id;
|
||||
|
||||
void ps_register(struct ps *ps);
|
||||
void ps_register_message(struct ps *ps, const char *name, void *ref);
|
||||
|
||||
#define LOG(fmt, args...) \
|
||||
do { \
|
||||
|
Loading…
Reference in New Issue
Block a user