diff --git a/plugins/fastrouter/fastrouter.c b/plugins/fastrouter/fastrouter.c index e3d635e4..9b87a201 100644 --- a/plugins/fastrouter/fastrouter.c +++ b/plugins/fastrouter/fastrouter.c @@ -517,7 +517,7 @@ void fastrouter_loop() { fr_session->instance_address = tmp_socket_name; } else if (ufr.subscription_server) { - fr_session->un = uwsgi_get_subscribe_node(ufr.subscriptions, fr_session->hostname, fr_session->hostname_len, 0); + fr_session->un = uwsgi_get_subscribe_node(&ufr.subscriptions, fr_session->hostname, fr_session->hostname_len, 0); if (fr_session->un && fr_session->un->len) { fr_session->instance_address = fr_session->un->name; fr_session->instance_address_len = fr_session->un->len; diff --git a/plugins/http/http.c b/plugins/http/http.c index 21a2591c..6e446f5d 100644 --- a/plugins/http/http.c +++ b/plugins/http/http.c @@ -637,7 +637,7 @@ void http_loop() { uhttp_session->instance_address_len = uhttp.to_len; } else if (uhttp.subscription_server) { - uhttp_session->un = uwsgi_get_subscribe_node(uhttp.subscriptions, uhttp_session->hostname, uhttp_session->hostname_len, 0); + uhttp_session->un = uwsgi_get_subscribe_node(&uhttp.subscriptions, uhttp_session->hostname, uhttp_session->hostname_len, 0); if (uhttp_session->un && uhttp_session->un->len) { uhttp_session->instance_address = uhttp_session->un->name; uhttp_session->instance_address_len = uhttp_session->un->len; diff --git a/subscription.c b/subscription.c index 4d33f464..db5318c3 100644 --- a/subscription.c +++ b/subscription.c @@ -16,9 +16,9 @@ */ -struct uwsgi_subscribe_slot *uwsgi_get_subscribe_slot(struct uwsgi_subscribe_slot *slot, char *key, uint16_t keylen, int regexp) { +struct uwsgi_subscribe_slot *uwsgi_get_subscribe_slot(struct uwsgi_subscribe_slot **slot, char *key, uint16_t keylen, int regexp) { - struct uwsgi_subscribe_slot *current_slot = slot; + struct uwsgi_subscribe_slot *current_slot = *slot; if (keylen > 0xff) return NULL; @@ -34,11 +34,16 @@ struct uwsgi_subscribe_slot *uwsgi_get_subscribe_slot(struct uwsgi_subscribe_slo if (slot_parent) { slot_parent->next = current_slot; } + else { + *slot = current_slot; + } + slot_prev->prev = current_slot; slot_prev->next = current_slot->next; - current_slot->prev = slot_parent; current_slot->next = slot_prev; + current_slot->prev = slot_parent; + } } return current_slot; @@ -50,7 +55,7 @@ struct uwsgi_subscribe_slot *uwsgi_get_subscribe_slot(struct uwsgi_subscribe_slo return NULL; } -struct uwsgi_subscribe_node *uwsgi_get_subscribe_node(struct uwsgi_subscribe_slot *slot, char *key, uint16_t keylen, int regexp) { +struct uwsgi_subscribe_node *uwsgi_get_subscribe_node(struct uwsgi_subscribe_slot **slot, char *key, uint16_t keylen, int regexp) { if (keylen > 0xff) return NULL; @@ -121,7 +126,7 @@ void uwsgi_remove_subscribe_node(struct uwsgi_subscribe_slot **slot, struct uwsg struct uwsgi_subscribe_node *uwsgi_add_subscribe_node(struct uwsgi_subscribe_slot **slot, struct uwsgi_subscribe_req *usr, int regexp) { - struct uwsgi_subscribe_slot *current_slot = uwsgi_get_subscribe_slot(*slot, usr->key, usr->keylen, regexp), *old_slot = NULL, *a_slot; + struct uwsgi_subscribe_slot *current_slot = uwsgi_get_subscribe_slot(slot, usr->key, usr->keylen, regexp), *old_slot = NULL, *a_slot; struct uwsgi_subscribe_node *node, *old_node = NULL; if (usr->address_len > 0xff) return NULL; diff --git a/uwsgi.h b/uwsgi.h index 719631a4..1412e6c4 100644 --- a/uwsgi.h +++ b/uwsgi.h @@ -2435,8 +2435,8 @@ struct uwsgi_subscribe_slot { }; -struct uwsgi_subscribe_slot *uwsgi_get_subscribe_slot(struct uwsgi_subscribe_slot *, char *, uint16_t, int); -struct uwsgi_subscribe_node *uwsgi_get_subscribe_node(struct uwsgi_subscribe_slot *, char *, uint16_t, int); +struct uwsgi_subscribe_slot *uwsgi_get_subscribe_slot(struct uwsgi_subscribe_slot **, char *, uint16_t, int); +struct uwsgi_subscribe_node *uwsgi_get_subscribe_node(struct uwsgi_subscribe_slot **, char *, uint16_t, int); void uwsgi_remove_subscribe_node(struct uwsgi_subscribe_slot **, struct uwsgi_subscribe_node *); struct uwsgi_subscribe_node *uwsgi_add_subscribe_node(struct uwsgi_subscribe_slot **, struct uwsgi_subscribe_req *, int);