diff options
author | Sander Vrijders <sander.vrijders@ugent.be> | 2017-03-21 15:26:04 +0100 |
---|---|---|
committer | Sander Vrijders <sander.vrijders@ugent.be> | 2017-03-21 15:30:33 +0100 |
commit | 933a7b93a679b994214c49540d891a901c7d5458 (patch) | |
tree | 23ebcbec3857b3322a9b6cb6f36463ae4157ee15 /src/ipcpd/normal/main.c | |
parent | 3bb7ed41f8c96a15f16281f3c9f282e6690aed38 (diff) | |
download | ouroboros-933a7b93a679b994214c49540d891a901c7d5458.tar.gz ouroboros-933a7b93a679b994214c49540d891a901c7d5458.zip |
ipcpd: normal: Split fmgr init into init and start
This split the initialization of the flow manager into an init part
and a start part. This avoids the usage of data structures that have
not been properly initialized yet.
Diffstat (limited to 'src/ipcpd/normal/main.c')
-rw-r--r-- | src/ipcpd/normal/main.c | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/src/ipcpd/normal/main.c b/src/ipcpd/normal/main.c index 398d6ee3..7acf3046 100644 --- a/src/ipcpd/normal/main.c +++ b/src/ipcpd/normal/main.c @@ -143,25 +143,27 @@ static int boot_components(void) log_dbg("Ribmgr started."); - if (fmgr_init()) { + if (frct_init()) { dir_fini(); ribmgr_fini(); addr_auth_fini(); - log_err("Failed to start flow manager."); + log_err("Failed to initialize FRCT."); return -1; } - if (frct_init()) { - fmgr_fini(); + if (fmgr_start()) { + frct_fini(); dir_fini(); ribmgr_fini(); addr_auth_fini(); - log_err("Failed to initialize FRCT."); + log_err("Failed to start flow manager."); return -1; } + if (enroll_start()) { - fmgr_fini(); + fmgr_stop(); + frct_fini(); dir_fini(); ribmgr_fini(); addr_auth_fini(); @@ -174,8 +176,8 @@ static int boot_components(void) if (connmgr_start()) { ipcp_set_state(IPCP_INIT); enroll_stop(); + fmgr_stop(); frct_fini(); - fmgr_fini(); dir_fini(); ribmgr_fini(); addr_auth_fini(); @@ -194,7 +196,7 @@ void shutdown_components(void) frct_fini(); - fmgr_fini(); + fmgr_stop(); dir_fini(); @@ -418,7 +420,6 @@ int main(int argc, exit(EXIT_FAILURE); } - if (connmgr_init()) { log_err("Failed to initialize connection manager."); ipcp_create_r(getpid(), -1); @@ -438,11 +439,23 @@ int main(int argc, exit(EXIT_FAILURE); } + if (fmgr_init()) { + log_err("Failed to initialize flow manager component."); + ipcp_create_r(getpid(), -1); + enroll_fini(); + connmgr_fini(); + rib_fini(); + irm_unbind_api(getpid(), ipcpi.name); + ipcp_fini(); + exit(EXIT_FAILURE); + } + pthread_sigmask(SIG_BLOCK, &sigset, NULL); if (ipcp_boot() < 0) { log_err("Failed to boot IPCP."); ipcp_create_r(getpid(), -1); + fmgr_fini(); enroll_fini(); connmgr_fini(); rib_fini(); @@ -457,6 +470,7 @@ int main(int argc, log_err("Failed to notify IRMd we are initialized."); ipcp_set_state(IPCP_NULL); ipcp_shutdown(); + fmgr_fini(); enroll_fini(); connmgr_fini(); rib_fini(); @@ -470,12 +484,14 @@ int main(int argc, if (ipcp_get_state() == IPCP_SHUTDOWN) shutdown_components(); - rib_fini(); + fmgr_fini(); enroll_fini(); connmgr_fini(); + rib_fini(); + irm_unbind_api(getpid(), ipcpi.name); ipcp_fini(); |