From: Maria Matejka Date: Tue, 3 Sep 2024 10:24:27 +0000 (+0200) Subject: Thread config has an explicit structure X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ce406158162c98a3fc03f41373e9a2b7d809ddc6;p=thirdparty%2Fbird.git Thread config has an explicit structure --- diff --git a/conf/conf.h b/conf/conf.h index db261e56e..370518825 100644 --- a/conf/conf.h +++ b/conf/conf.h @@ -65,7 +65,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 1923af4e6..cd4e2132b 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 303769153..d8b8bb653 100644 --- a/sysdep/unix/config.Y +++ b/sysdep/unix/config.Y @@ -147,7 +147,7 @@ cli_opts_block: 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 438373a70..bef177149 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 8a94b74d5..a183cb7a5 100644 --- a/sysdep/unix/main.c +++ b/sysdep/unix/main.c @@ -227,13 +227,14 @@ sysdep_preconfig(struct config *c) static void cli_commit(struct config *new, struct config *old); 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); - - cli_commit(new, old); - bird_thread_commit(new, old); + cli_commit(new, old); + bird_thread_commit(&new->threads); + } } static int diff --git a/sysdep/unix/unix.h b/sysdep/unix/unix.h index 4132c6333..471a21e41 100644 --- a/sysdep/unix/unix.h +++ b/sysdep/unix/unix.h @@ -39,7 +39,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 a8b87fc20..b5ea4cb06 100644 --- a/test/birdtest.c +++ b/test/birdtest.c @@ -559,10 +559,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) {}