diff options
author | dimitri staessens <dimitri.staessens@ugent.be> | 2017-03-20 14:31:08 +0100 |
---|---|---|
committer | dimitri staessens <dimitri.staessens@ugent.be> | 2017-03-20 14:31:08 +0100 |
commit | d14259796288f9d3eae907408b3c9c2e8c750a9c (patch) | |
tree | d456bab4d552eef20df03f24b5f867b64e1065ff | |
parent | 6d6e1e2beec5bc003e490b8f96d861e6e8f7295d (diff) | |
download | ouroboros-d14259796288f9d3eae907408b3c9c2e8c750a9c.tar.gz ouroboros-d14259796288f9d3eae907408b3c9c2e8c750a9c.zip |
ipcpd: Create CDAP instance before connecting
This lessens the likelyhood that the CDAP SDU thread is not yet active
when a new connection starts sending CDAP messages.
-rw-r--r-- | src/ipcpd/normal/enroll.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/ipcpd/normal/enroll.c b/src/ipcpd/normal/enroll.c index bdf55fe8..7e15be11 100644 --- a/src/ipcpd/normal/enroll.c +++ b/src/ipcpd/normal/enroll.c @@ -73,15 +73,15 @@ static void * enroll_handle(void * o) (void) o; while (true) { - if (connmgr_wait(enroll.ae, &conn)) { - log_err("Failed to get next connection."); - continue; - } - cdap = cdap_create(); if (cdap == NULL) { log_err("Failed to instantiate CDAP."); - flow_dealloc(conn.flow_info.fd); + continue; + } + + if (connmgr_wait(enroll.ae, &conn)) { + log_err("Failed to get next connection."); + cdap_destroy(cdap); continue; } @@ -179,17 +179,18 @@ int enroll_boot(char * dst_name) char * members_ro = MEMBERS_PATH; char * dif_ro = DIF_PATH; - if (connmgr_alloc(enroll.ae, dst_name, NULL, &conn)) { - log_err("Failed to get connection."); - return -1; - } - cdap = cdap_create(); if (cdap == NULL) { log_err("Failed to instantiate CDAP."); return -1; } + if (connmgr_alloc(enroll.ae, dst_name, NULL, &conn)) { + log_err("Failed to get connection."); + cdap_destroy(cdap); + return -1; + } + if (cdap_add_flow(cdap, conn.flow_info.fd)) { log_warn("Failed to add flow to CDAP."); cdap_destroy(cdap); |