summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@intec.ugent.be>2016-08-16 10:45:31 +0200
committerSander Vrijders <sander.vrijders@intec.ugent.be>2016-08-16 10:45:31 +0200
commitfbc0b71d3947cb6047e3e710d606ffc6a39778bc (patch)
tree0a5fead93b09bf15eae5851e4b022f05df3fdae5 /src
parent44cc6aaa41d88dc978a087178fd74a1c2dba70fd (diff)
parent54b1ba99e15660e2e12dbc564f7e7428b5440446 (diff)
downloadouroboros-fbc0b71d3947cb6047e3e710d606ffc6a39778bc.tar.gz
ouroboros-fbc0b71d3947cb6047e3e710d606ffc6a39778bc.zip
Merged in dstaesse/ouroboros/be-fix-normal (pull request #210)
ipcpd: Fix bootstrap with api_bind
Diffstat (limited to 'src')
-rw-r--r--src/ipcpd/ipcp-data.c4
-rw-r--r--src/ipcpd/ipcp-data.h1
-rw-r--r--src/ipcpd/ipcp.c8
-rw-r--r--src/ipcpd/normal/fmgr.c9
-rw-r--r--src/ipcpd/normal/main.c15
5 files changed, 27 insertions, 10 deletions
diff --git a/src/ipcpd/ipcp-data.c b/src/ipcpd/ipcp-data.c
index a2fef08c..593baeba 100644
--- a/src/ipcpd/ipcp-data.c
+++ b/src/ipcpd/ipcp-data.c
@@ -111,6 +111,7 @@ struct ipcp_data * ipcp_data_init(struct ipcp_data * dst,
return NULL;
dst->type = ipcp_type;
+ dst->dif_name = NULL;
/* init the lists */
INIT_LIST_HEAD(&dst->registry);
@@ -157,6 +158,9 @@ void ipcp_data_destroy(struct ipcp_data * data)
clear_registry(data);
clear_directory(data);
+ if (data->dif_name != NULL)
+ free(data->dif_name);
+
pthread_mutex_unlock(&data->dir_lock);
pthread_mutex_unlock(&data->reg_lock);
diff --git a/src/ipcpd/ipcp-data.h b/src/ipcpd/ipcp-data.h
index 5bf25649..36245eea 100644
--- a/src/ipcpd/ipcp-data.h
+++ b/src/ipcpd/ipcp-data.h
@@ -34,6 +34,7 @@
struct ipcp_data {
enum ipcp_type type;
+ char * dif_name;
struct list_head registry;
pthread_mutex_t reg_lock;
diff --git a/src/ipcpd/ipcp.c b/src/ipcpd/ipcp.c
index 5c066cb0..544b10df 100644
--- a/src/ipcpd/ipcp.c
+++ b/src/ipcpd/ipcp.c
@@ -184,7 +184,13 @@ void * ipcp_main_loop(void * o)
}
conf_msg = msg->conf;
conf.type = conf_msg->ipcp_type;
- conf.dif_name = conf_msg->dif_name;
+ conf.dif_name = strdup(conf_msg->dif_name);
+ if (conf.dif_name == NULL) {
+ ret_msg.has_result = true;
+ ret_msg.result = -1;
+ break;
+ }
+
if (conf_msg->ipcp_type == IPCP_NORMAL) {
conf.addr_size = conf_msg->addr_size;
conf.cep_id_size = conf_msg->cep_id_size;
diff --git a/src/ipcpd/normal/fmgr.c b/src/ipcpd/normal/fmgr.c
index 70afff37..437dac13 100644
--- a/src/ipcpd/normal/fmgr.c
+++ b/src/ipcpd/normal/fmgr.c
@@ -79,6 +79,7 @@ static void * fmgr_listen(void * o)
{
int fd;
char * ae_name;
+ bool bound = false;
while (true) {
pthread_mutex_lock(&_ipcp->state_lock);
@@ -93,6 +94,14 @@ static void * fmgr_listen(void * o)
}
pthread_mutex_unlock(&_ipcp->state_lock);
+ if (!bound && api_bind(_ipcp->data->dif_name) < 0) {
+ LOG_ERR("Failed to bind the server instance.");
+ pthread_mutex_unlock(&_ipcp->state_lock);
+ return (void *) -1;
+ }
+
+ bound = true;
+
fd = flow_accept(&ae_name);
if (fd < 0) {
LOG_ERR("Failed to accept flow.");
diff --git a/src/ipcpd/normal/main.c b/src/ipcpd/normal/main.c
index ea8d75e1..cf6ac728 100644
--- a/src/ipcpd/normal/main.c
+++ b/src/ipcpd/normal/main.c
@@ -101,7 +101,7 @@ static int normal_ipcp_name_reg(char * name)
if (_ipcp->state != IPCP_ENROLLED) {
pthread_mutex_unlock(&_ipcp->state_lock);
- LOG_DBGF("Won't register with non-enrolled IPCP.");
+ LOG_ERR("Won't register with non-enrolled IPCP.");
return -1; /* -ENOTENROLLED */
}
@@ -158,8 +158,6 @@ static int normal_ipcp_enroll(char * dif_name)
static int normal_ipcp_bootstrap(struct dif_config * conf)
{
- LOG_DBGF("Bootstrapping in DIF %s.", conf->dif_name);
-
pthread_mutex_lock(&_ipcp->state_lock);
if (_ipcp->state != IPCP_INIT) {
@@ -174,15 +172,14 @@ static int normal_ipcp_bootstrap(struct dif_config * conf)
return -1;
}
- if (api_bind(conf->dif_name) < 0) {
- LOG_ERR("Failed to bind the server AP instance.");
- return -1;
- }
-
ipcp_state_change(_ipcp, IPCP_ENROLLED);
+ _ipcp->data->dif_name = conf->dif_name;
+
pthread_mutex_unlock(&_ipcp->state_lock);
+ LOG_DBG("Bootstrapped in DIF %s.", conf->dif_name);
+
return 0;
}
@@ -248,7 +245,7 @@ void normal_ipcp_data_destroy()
pthread_mutex_unlock(&_ipcp->state_lock);
- free(_ipcp->data);
+ ipcp_data_destroy(_ipcp->data);
}
int main(int argc, char * argv[])