summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@ugent.be>2017-03-22 16:56:47 +0100
committerdimitri staessens <dimitri.staessens@ugent.be>2017-03-22 16:56:47 +0100
commit0d7852152ee4d46c825c1ee8143c3cb2f46c4d3d (patch)
tree93d25a413191c66a960b8c98b05236f18380e8df /src
parent7871c6fce718274abbd467912f1ec591f9115714 (diff)
downloadouroboros-0d7852152ee4d46c825c1ee8143c3cb2f46c4d3d.tar.gz
ouroboros-0d7852152ee4d46c825c1ee8143c3cb2f46c4d3d.zip
ipcpd: Create cdap instance at enroll_init
Diffstat (limited to 'src')
-rw-r--r--src/ipcpd/normal/enroll.c32
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;