diff options
author | dimitri staessens <[email protected]> | 2017-03-22 16:06:52 +0000 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2017-03-22 16:06:52 +0000 |
commit | 4d31a76040e3bc9218cd731f745c9ea4e38a2a5a (patch) | |
tree | 9fd26561be8e27f15d69129f6f7257a136888eb5 /src/ipcpd/normal/enroll.c | |
parent | 79090eb2fc0fe4f6582aca556c05435dace60046 (diff) | |
parent | 3964be811b57fca965b979b7c21f24532a172bd4 (diff) | |
download | ouroboros-4d31a76040e3bc9218cd731f745c9ea4e38a2a5a.tar.gz ouroboros-4d31a76040e3bc9218cd731f745c9ea4e38a2a5a.zip |
Merged in dstaesse/ouroboros/be-fixes (pull request #413)
Be fixes
Diffstat (limited to 'src/ipcpd/normal/enroll.c')
-rw-r--r-- | src/ipcpd/normal/enroll.c | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/src/ipcpd/normal/enroll.c b/src/ipcpd/normal/enroll.c index 7e15be11..0b0db1cf 100644 --- a/src/ipcpd/normal/enroll.c +++ b/src/ipcpd/normal/enroll.c @@ -46,8 +46,9 @@ #define ENROLL_WARN_TIME_OFFSET 20 struct { - struct ae * ae; - pthread_t listener; + struct ae * ae; + struct cdap * cdap; + pthread_t listener; } enroll; static void * enroll_handle(void * o) @@ -70,24 +71,18 @@ static void * enroll_handle(void * o) char * members_ro = MEMBERS_PATH; char * dif_ro = DIF_PATH; - (void) o; + cdap = (struct cdap *) o; - while (true) { - cdap = cdap_create(); - if (cdap == NULL) { - log_err("Failed to instantiate CDAP."); - continue; - } + assert(cdap); + while (true) { if (connmgr_wait(enroll.ae, &conn)) { log_err("Failed to get next connection."); - cdap_destroy(cdap); continue; } if (cdap_add_flow(cdap, conn.flow_info.fd)) { log_warn("Failed to add flow to CDAP."); - cdap_destroy(cdap); flow_dealloc(conn.flow_info.fd); continue; } @@ -155,7 +150,7 @@ static void * enroll_handle(void * o) log_dbg("Sent boot info to new member."); - cdap_destroy(cdap); + cdap_del_flow(cdap, conn.flow_info.fd); flow_dealloc(conn.flow_info.fd); } @@ -337,6 +332,12 @@ int enroll_init(void) { struct conn_info info; + enroll.cdap = cdap_create(); + if (enroll.cdap == NULL) { + log_err("Failed to instantiate CDAP."); + return -1; + } + memset(&info, 0, sizeof(info)); strcpy(info.ae_name, ENROLL_AE); @@ -345,20 +346,23 @@ int enroll_init(void) info.pref_syntax = PROTO_GPB; enroll.ae = connmgr_ae_create(info); - if (enroll.ae == NULL) + if (enroll.ae == NULL) { + cdap_destroy(enroll.cdap); return -1; + } return 0; } void enroll_fini(void) { + cdap_destroy(enroll.cdap); connmgr_ae_destroy(enroll.ae); } int enroll_start(void) { - if (pthread_create(&enroll.listener, NULL, enroll_handle, NULL)) + if (pthread_create(&enroll.listener, NULL, enroll_handle, enroll.cdap)) return -1; return 0; |