From c80c93f11dbfb1b0c07f9a6f8b8d91024e5db507 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Sun, 8 Mar 2020 13:29:21 +0100 Subject: irm: Revise naming API This revises the naming API to treat names (or reg_name in the source) as first-class citizens of the architecture. This is more in line with the way they are described in the article. Operations have been added to create/destroy names independently of registering. This was previously done only as part of register, and there was no way to delete a name from the IRMd. The create call now allows specifying a policy for load-balancing incoming flows for a name. The default is the new round-robin load-balancer, the previous behaviour is still available as a spillover load-balancer. The register calls will still create a name if it doesn't exist, with the default round-robin load-balancer. The tools now have a "name" section, so the format is now irm name ... Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/irmd/registry.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'src/irmd/registry.c') diff --git a/src/irmd/registry.c b/src/irmd/registry.c index ef0bc8cc..66cc5af3 100644 --- a/src/irmd/registry.c +++ b/src/irmd/registry.c @@ -32,7 +32,6 @@ #include #include -#include #include #include "registry.h" @@ -72,7 +71,8 @@ static int reg_entry_init(struct reg_entry * e, list_head_init(&e->reg_progs); list_head_init(&e->reg_pids); - e->name = name; + e->name = name; + e->pol_lb = 0; if (pthread_condattr_init(&cattr)) goto fail_cattr; @@ -286,7 +286,17 @@ int reg_entry_add_pid(struct reg_entry * e, i->pid = pid; - list_add(&i->next, &e->reg_pids); + /* load balancing policy assigns queue order for this process. */ + switch(e->pol_lb) { + case LB_RR: /* Round robin policy. */ + list_add_tail(&i->next, &e->reg_pids); + break; + case LB_SPILL: /* Keep accepting flows on the current process */ + list_add(&i->next, &e->reg_pids); + break; + default: + assert(false); + }; if (e->state == REG_NAME_IDLE || e->state == REG_NAME_AUTO_ACCEPT || @@ -300,6 +310,13 @@ int reg_entry_add_pid(struct reg_entry * e, return 0; } +void reg_entry_set_policy(struct reg_entry * e, + enum pol_balance p) +{ + e->pol_lb = p; +} + + static void reg_entry_check_state(struct reg_entry * e) { assert(e); -- cgit v1.2.3