From d14259796288f9d3eae907408b3c9c2e8c750a9c Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Mon, 20 Mar 2017 14:31:08 +0100 Subject: 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. --- src/ipcpd/normal/enroll.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'src/ipcpd/normal') 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); -- cgit v1.2.3