From 8e4e526f811fb0e1d358f79707d488b619a60e47 Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Tue, 15 Aug 2017 22:23:03 +0200 Subject: ipcpd: Refactor normal IPCP failure handling --- src/ipcpd/normal/main.c | 59 ++++++++++++++++++++----------------------------- 1 file changed, 24 insertions(+), 35 deletions(-) (limited to 'src/ipcpd/normal') diff --git a/src/ipcpd/normal/main.c b/src/ipcpd/normal/main.c index 325c1285..27fefdb6 100644 --- a/src/ipcpd/normal/main.c +++ b/src/ipcpd/normal/main.c @@ -366,66 +366,39 @@ int main(int argc, char * argv[]) { if (ipcp_init(argc, argv, THIS_TYPE, &normal_ops) < 0) { - ipcp_create_r(getpid(), -1); - exit(EXIT_FAILURE); + log_err("Failed to init IPCP."); + goto fail_init; } if (irm_bind_api(getpid(), ipcpi.name)) { log_err("Failed to bind AP name."); - ipcp_create_r(getpid(), -1); - ipcp_fini(); - exit(EXIT_FAILURE); + goto fail_bind_api; } if (rib_init()) { log_err("Failed to initialize RIB."); - ipcp_create_r(getpid(), -1); - irm_unbind_api(getpid(), ipcpi.name); - ipcp_fini(); - exit(EXIT_FAILURE); + goto fail_rib_init; } if (connmgr_init()) { log_err("Failed to initialize connection manager."); - ipcp_create_r(getpid(), -1); - rib_fini(); - irm_unbind_api(getpid(), ipcpi.name); - ipcp_fini(); - exit(EXIT_FAILURE); + goto fail_connmgr_init; } if (enroll_init()) { log_err("Failed to initialize enroll component."); - ipcp_create_r(getpid(), -1); - connmgr_fini(); - rib_fini(); - irm_unbind_api(getpid(), ipcpi.name); - ipcp_fini(); - exit(EXIT_FAILURE); + goto fail_enroll_init; } - if (ipcp_boot() < 0) { log_err("Failed to boot IPCP."); - ipcp_create_r(getpid(), -1); - enroll_fini(); - connmgr_fini(); - rib_fini(); - irm_unbind_api(getpid(), ipcpi.name); - ipcp_fini(); - exit(EXIT_FAILURE); + goto fail_boot; } if (ipcp_create_r(getpid(), 0)) { log_err("Failed to notify IRMd we are initialized."); ipcp_set_state(IPCP_NULL); - ipcp_shutdown(); - enroll_fini(); - connmgr_fini(); - rib_fini(); - irm_unbind_api(getpid(), ipcpi.name); - ipcp_fini(); - exit(EXIT_FAILURE); + goto fail_create_r; } ipcp_shutdown(); @@ -444,4 +417,20 @@ int main(int argc, ipcp_fini(); exit(EXIT_SUCCESS); + + fail_create_r: + ipcp_shutdown(); + fail_boot: + enroll_fini(); + fail_enroll_init: + connmgr_fini(); + fail_connmgr_init: + rib_fini(); + fail_rib_init: + irm_unbind_api(getpid(), ipcpi.name); + fail_bind_api: + ipcp_fini(); + fail_init: + ipcp_create_r(getpid(), -1); + exit(EXIT_FAILURE); } -- cgit v1.2.3 From a27bef54052b81406ba3142be3da4ab2a6330de6 Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Tue, 15 Aug 2017 22:25:54 +0200 Subject: ipcpd: Fix missing clock_gettime in flow allocator --- src/ipcpd/normal/fa.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/ipcpd/normal') diff --git a/src/ipcpd/normal/fa.c b/src/ipcpd/normal/fa.c index 06f10b53..2488f017 100644 --- a/src/ipcpd/normal/fa.c +++ b/src/ipcpd/normal/fa.c @@ -287,6 +287,8 @@ int fa_alloc_resp(int fd, struct shm_du_buff * sdb; qoscube_t qc; + clock_gettime(PTHREAD_COND_CLOCK, &abstime); + pthread_mutex_lock(&ipcpi.alloc_lock); while (ipcpi.alloc_id != fd && ipcp_get_state() == IPCP_OPERATIONAL) { -- cgit v1.2.3