mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-11-08 12:18:42 +00:00
Config obstacles are lockless now
This commit is contained in:
parent
5ba9878b4f
commit
7776e47e32
19
conf/conf.c
19
conf/conf.c
@ -70,7 +70,7 @@ static int future_cftype; /* Type of scheduled transition, may also be RECONFIG
|
|||||||
/* Note that when future_cftype is RECONFIG_UNDO, then future_config is NULL,
|
/* Note that when future_cftype is RECONFIG_UNDO, then future_config is NULL,
|
||||||
therefore proper check for future scheduled config checks future_cftype */
|
therefore proper check for future scheduled config checks future_cftype */
|
||||||
|
|
||||||
static event *config_event; /* Event for finalizing reconfiguration */
|
static void config_done(void *cf);
|
||||||
static timer *config_timer; /* Timer for scheduled configuration rollback */
|
static timer *config_timer; /* Timer for scheduled configuration rollback */
|
||||||
|
|
||||||
/* These are public just for cmd_show_status(), should not be accessed elsewhere */
|
/* These are public just for cmd_show_status(), should not be accessed elsewhere */
|
||||||
@ -110,6 +110,8 @@ config_alloc(const char *name)
|
|||||||
c->tf_base = c->tf_log = TM_ISO_LONG_MS;
|
c->tf_base = c->tf_log = TM_ISO_LONG_MS;
|
||||||
c->gr_wait = DEFAULT_GR_WAIT;
|
c->gr_wait = DEFAULT_GR_WAIT;
|
||||||
|
|
||||||
|
c->done_event = (event) { .hook = config_done, .data = c, };
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,16 +230,15 @@ void
|
|||||||
config_add_obstacle(struct config *c)
|
config_add_obstacle(struct config *c)
|
||||||
{
|
{
|
||||||
DBG("+++ adding obstacle %d\n", c->obstacle_count);
|
DBG("+++ adding obstacle %d\n", c->obstacle_count);
|
||||||
c->obstacle_count++;
|
atomic_fetch_add_explicit(&c->obstacle_count, 1, memory_order_acq_rel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
config_del_obstacle(struct config *c)
|
config_del_obstacle(struct config *c)
|
||||||
{
|
{
|
||||||
DBG("+++ deleting obstacle %d\n", c->obstacle_count);
|
DBG("+++ deleting obstacle %d\n", c->obstacle_count);
|
||||||
c->obstacle_count--;
|
if (atomic_fetch_sub_explicit(&c->obstacle_count, 1, memory_order_acq_rel) == 1)
|
||||||
if (!c->obstacle_count && (c != config))
|
ev_send_loop(&main_birdloop, &c->done_event);
|
||||||
ev_schedule(config_event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -313,8 +314,11 @@ config_do_commit(struct config *c, int type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
config_done(void *unused UNUSED)
|
config_done(void *cf)
|
||||||
{
|
{
|
||||||
|
if (cf == config)
|
||||||
|
return;
|
||||||
|
|
||||||
if (config->shutdown)
|
if (config->shutdown)
|
||||||
sysdep_shutdown_done();
|
sysdep_shutdown_done();
|
||||||
|
|
||||||
@ -517,9 +521,6 @@ config_init(void)
|
|||||||
{
|
{
|
||||||
config_pool = rp_new(&root_pool, the_bird_domain.the_bird, "Configurations");
|
config_pool = rp_new(&root_pool, the_bird_domain.the_bird, "Configurations");
|
||||||
|
|
||||||
config_event = ev_new(config_pool);
|
|
||||||
config_event->hook = config_done;
|
|
||||||
|
|
||||||
config_timer = tm_new(config_pool);
|
config_timer = tm_new(config_pool);
|
||||||
config_timer->hook = config_timeout;
|
config_timer->hook = config_timeout;
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,8 @@ struct config {
|
|||||||
int thread_count; /* How many worker threads to prefork */
|
int thread_count; /* How many worker threads to prefork */
|
||||||
|
|
||||||
struct sym_scope *root_scope; /* Scope for root symbols */
|
struct sym_scope *root_scope; /* Scope for root symbols */
|
||||||
int obstacle_count; /* Number of items blocking freeing of this config */
|
_Atomic int obstacle_count; /* Number of items blocking freeing of this config */
|
||||||
|
event done_event; /* Called when obstacle_count reaches zero */
|
||||||
int shutdown; /* This is a pseudo-config for daemon shutdown */
|
int shutdown; /* This is a pseudo-config for daemon shutdown */
|
||||||
int gr_down; /* This is a pseudo-config for graceful restart */
|
int gr_down; /* This is a pseudo-config for graceful restart */
|
||||||
btime load_time; /* When we've got this configuration */
|
btime load_time; /* When we've got this configuration */
|
||||||
|
Loading…
Reference in New Issue
Block a user