diff --git a/conf/conf.h b/conf/conf.h index 60c89267..2320cc07 100644 --- a/conf/conf.h +++ b/conf/conf.h @@ -63,7 +63,7 @@ struct config { char *err_file_name; /* File name containing error */ char *file_name; /* Name of main configuration file */ int file_fd; /* File descriptor of main configuration file */ - int thread_count; /* How many worker threads to prefork */ + struct thread_config threads; /* Thread settings */ struct sym_scope *root_scope; /* Scope for root symbols */ struct sym_scope *current_scope; /* Current scope where we are actually in while parsing */ diff --git a/lib/io-loop.h b/lib/io-loop.h index 1923af4e..cd4e2132 100644 --- a/lib/io-loop.h +++ b/lib/io-loop.h @@ -73,6 +73,14 @@ void birdloop_ping(struct birdloop *loop); void birdloop_add_socket(struct birdloop *, struct birdsock *); void birdloop_remove_socket(struct birdloop *, struct birdsock *); +/* Initializations */ void birdloop_init(void); +struct thread_config { + uint count; +}; + +void bird_thread_commit(struct thread_config *new); + + #endif /* _BIRD_IO_LOOP_H_ */ diff --git a/sysdep/unix/config.Y b/sysdep/unix/config.Y index 60541e44..c00c2377 100644 --- a/sysdep/unix/config.Y +++ b/sysdep/unix/config.Y @@ -125,7 +125,7 @@ mrtdump_base: conf: THREADS expr { if ($2 < 1) cf_error("Number of threads must be at least one."); - new_config->thread_count = $2; + new_config->threads.count = $2; } diff --git a/sysdep/unix/io-loop.c b/sysdep/unix/io-loop.c index 438373a7..bef17714 100644 --- a/sysdep/unix/io-loop.c +++ b/sysdep/unix/io-loop.c @@ -1106,22 +1106,19 @@ bird_thread_shutdown(void * _ UNUSED) } void -bird_thread_commit(struct config *new, struct config *old UNUSED) +bird_thread_commit(struct thread_config *new) { ASSERT_DIE(birdloop_inside(&main_birdloop)); - if (new->shutdown) - return; - - if (!new->thread_count) - new->thread_count = 1; + if (!new->count) + new->count = 1; while (1) { struct birdloop_pickup_group *group = &pickup_groups[0]; LOCK_DOMAIN(attrs, group->domain); - int dif = group->thread_count - (thread_dropper_goal = new->thread_count); + int dif = group->thread_count - (thread_dropper_goal = new->count); bool thread_dropper_running = !!thread_dropper; UNLOCK_DOMAIN(attrs, group->domain); diff --git a/sysdep/unix/main.c b/sysdep/unix/main.c index 42503eb0..345cc417 100644 --- a/sysdep/unix/main.c +++ b/sysdep/unix/main.c @@ -203,12 +203,13 @@ sysdep_preconfig(struct config *c) } void -sysdep_commit(struct config *new, struct config *old) +sysdep_commit(struct config *new, struct config *old UNUSED) { if (!new->shutdown) + { log_switch(0, &new->logfiles, new->syslog_name); - - bird_thread_commit(new, old); + bird_thread_commit(&new->threads); + } } static int diff --git a/sysdep/unix/unix.h b/sysdep/unix/unix.h index 7832caaa..71bc7a6c 100644 --- a/sysdep/unix/unix.h +++ b/sysdep/unix/unix.h @@ -38,7 +38,6 @@ void cmd_reconfig_status(void); void cmd_shutdown(void); void cmd_graceful_restart(void); void cmd_show_threads(int); -void bird_thread_commit(struct config *new, struct config *old); #define UNIX_DEFAULT_CONFIGURE_TIMEOUT 300 diff --git a/test/birdtest.c b/test/birdtest.c index 2072ada9..4b1ed7d7 100644 --- a/test/birdtest.c +++ b/test/birdtest.c @@ -557,10 +557,10 @@ void cmd_reconfig_undo_notify(void) {} #include "conf/conf.h" void sysdep_preconfig(struct config *c UNUSED) {} -void bird_thread_commit(struct config *new, struct config *old); -void sysdep_commit(struct config *new, struct config *old) +void bird_thread_commit(struct thread_config *new); +void sysdep_commit(struct config *new, struct config *old UNUSED) { - bird_thread_commit(new, old); + bird_thread_commit(&new->threads); } void sysdep_shutdown_done(void) {}