0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-11-13 22:58:42 +00:00

Thread config has an explicit structure

This commit is contained in:
Maria Matejka 2024-09-03 12:24:27 +02:00
parent 0f9d8c9ec0
commit bb3c3f3a7a
7 changed files with 21 additions and 16 deletions

View File

@ -63,7 +63,7 @@ struct config {
char *err_file_name; /* File name containing error */ char *err_file_name; /* File name containing error */
char *file_name; /* Name of main configuration file */ char *file_name; /* Name of main configuration file */
int file_fd; /* File descriptor 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 *root_scope; /* Scope for root symbols */
struct sym_scope *current_scope; /* Current scope where we are actually in while parsing */ struct sym_scope *current_scope; /* Current scope where we are actually in while parsing */

View File

@ -73,6 +73,14 @@ void birdloop_ping(struct birdloop *loop);
void birdloop_add_socket(struct birdloop *, struct birdsock *); void birdloop_add_socket(struct birdloop *, struct birdsock *);
void birdloop_remove_socket(struct birdloop *, struct birdsock *); void birdloop_remove_socket(struct birdloop *, struct birdsock *);
/* Initializations */
void birdloop_init(void); void birdloop_init(void);
struct thread_config {
uint count;
};
void bird_thread_commit(struct thread_config *new);
#endif /* _BIRD_IO_LOOP_H_ */ #endif /* _BIRD_IO_LOOP_H_ */

View File

@ -125,7 +125,7 @@ mrtdump_base:
conf: THREADS expr { conf: THREADS expr {
if ($2 < 1) cf_error("Number of threads must be at least one."); if ($2 < 1) cf_error("Number of threads must be at least one.");
new_config->thread_count = $2; new_config->threads.count = $2;
} }

View File

@ -1106,22 +1106,19 @@ bird_thread_shutdown(void * _ UNUSED)
} }
void void
bird_thread_commit(struct config *new, struct config *old UNUSED) bird_thread_commit(struct thread_config *new)
{ {
ASSERT_DIE(birdloop_inside(&main_birdloop)); ASSERT_DIE(birdloop_inside(&main_birdloop));
if (new->shutdown) if (!new->count)
return; new->count = 1;
if (!new->thread_count)
new->thread_count = 1;
while (1) while (1)
{ {
struct birdloop_pickup_group *group = &pickup_groups[0]; struct birdloop_pickup_group *group = &pickup_groups[0];
LOCK_DOMAIN(attrs, group->domain); 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; bool thread_dropper_running = !!thread_dropper;
UNLOCK_DOMAIN(attrs, group->domain); UNLOCK_DOMAIN(attrs, group->domain);

View File

@ -203,12 +203,13 @@ sysdep_preconfig(struct config *c)
} }
void void
sysdep_commit(struct config *new, struct config *old) sysdep_commit(struct config *new, struct config *old UNUSED)
{ {
if (!new->shutdown) if (!new->shutdown)
{
log_switch(0, &new->logfiles, new->syslog_name); log_switch(0, &new->logfiles, new->syslog_name);
bird_thread_commit(&new->threads);
bird_thread_commit(new, old); }
} }
static int static int

View File

@ -38,7 +38,6 @@ void cmd_reconfig_status(void);
void cmd_shutdown(void); void cmd_shutdown(void);
void cmd_graceful_restart(void); void cmd_graceful_restart(void);
void cmd_show_threads(int); void cmd_show_threads(int);
void bird_thread_commit(struct config *new, struct config *old);
#define UNIX_DEFAULT_CONFIGURE_TIMEOUT 300 #define UNIX_DEFAULT_CONFIGURE_TIMEOUT 300

View File

@ -557,10 +557,10 @@ void cmd_reconfig_undo_notify(void) {}
#include "conf/conf.h" #include "conf/conf.h"
void sysdep_preconfig(struct config *c UNUSED) {} void sysdep_preconfig(struct config *c UNUSED) {}
void bird_thread_commit(struct config *new, struct config *old); void bird_thread_commit(struct thread_config *new);
void sysdep_commit(struct config *new, struct config *old) 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) {} void sysdep_shutdown_done(void) {}