]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Thread config has an explicit structure
authorMaria Matejka <mq@ucw.cz>
Tue, 3 Sep 2024 10:24:27 +0000 (12:24 +0200)
committerMaria Matejka <mq@ucw.cz>
Sun, 23 Feb 2025 17:31:45 +0000 (18:31 +0100)
conf/conf.h
lib/io-loop.h
sysdep/unix/config.Y
sysdep/unix/io-loop.c
sysdep/unix/main.c
sysdep/unix/unix.h
test/birdtest.c

index db261e56eadf881e272346ad0ec6c38cb73c30e2..37051882572b69c723d78a36c48c1be6d3282ed0 100644 (file)
@@ -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 */
index 1923af4e67838688db474a49037fe0df6a82a9ad..cd4e2132b973d925bf9b94d481f6948cef919797 100644 (file)
@@ -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_ */
index 303769153847ab0b44b22e548c16e0b302584b51..d8b8bb653b0b857757fae89fd14631432c5f4656 100644 (file)
@@ -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;
 }
 
 
index 438373a70541e6ef2a6817a6d51634bdbcb25c33..bef177149e181aa1fd9c54bf1223ad568ba40606 100644 (file)
@@ -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);
index 8a94b74d51fc7373e23f7bf224eeeb6059b21b03..a183cb7a54b879bc1faa936e7537c41db58466d4 100644 (file)
@@ -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
index 4132c6333adbcb698eeb0738d7d884bf9f756d81..471a21e410ef6e86152cd8cef765684b6b7a388a 100644 (file)
@@ -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
 
index a8b87fc204793c0fb05a218201f70db45e8a7c01..b5ea4cb06271a5f50820bd5a200d9c2718a51859 100644 (file)
@@ -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) {}