From 1ea22e8293924ae671dd142b76c8d6e68fbcafde Mon Sep 17 00:00:00 2001
From: dimitri staessens <dimitri.staessens@intec.ugent.be>
Date: Thu, 1 Sep 2016 09:01:53 +0200
Subject: irmd: Fix registering AP-I before bind

---
 src/irmd/main.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

(limited to 'src/irmd')

diff --git a/src/irmd/main.c b/src/irmd/main.c
index 465415b8..a69dd526 100644
--- a/src/irmd/main.c
+++ b/src/irmd/main.c
@@ -579,6 +579,7 @@ static int bind_api(pid_t  api,
 {
         char * name_dup = NULL;
         struct api_entry * e = NULL;
+        struct reg_entry * re = NULL;
 
         if (name == NULL)
                 return -EINVAL;
@@ -617,6 +618,10 @@ static int bind_api(pid_t  api,
                 return -1;
         }
 
+        re = registry_get_entry(&irmd->registry, name);
+        if (re != NULL && reg_entry_add_api(re, api) < 0)
+                LOG_ERR("Failed adding AP-I %d for name %s.", api, name);
+
         pthread_rwlock_unlock(&irmd->reg_lock);
         pthread_rwlock_unlock(&irmd->state_lock);
 
@@ -923,7 +928,7 @@ static int api_announce(pid_t api, char * apn)
                         }
 
                         list_add(&n->next, &e->names);
-                        LOG_DBG("API %d inherits listen name %s from AP %s.",
+                        LOG_DBG("AP-I %d inherits listen name %s from AP %s.",
                                 api, n->str, e->apn);
                 }
         }
@@ -1307,7 +1312,7 @@ static pid_t auto_execute(char ** argv)
         }
 
         if (api != 0) {
-                LOG_INFO("Instantiated %s as AP-i %d.", argv[0], api);
+                LOG_INFO("Instantiated %s as AP-I %d.", argv[0], api);
                 return api;
         }
 
-- 
cgit v1.2.3