diff options
Diffstat (limited to 'src/irmd/main.c')
| -rw-r--r-- | src/irmd/main.c | 16 | 
1 files changed, 10 insertions, 6 deletions
| diff --git a/src/irmd/main.c b/src/irmd/main.c index 06cf0e07..8ac645df 100644 --- a/src/irmd/main.c +++ b/src/irmd/main.c @@ -1286,15 +1286,16 @@ static pid_t auto_execute(char ** argv)                  return -1;          } -        LOG_INFO("Executing %s.", argv[0]);          api = fork();          if (api == -1) {                  LOG_ERR("Failed to fork");                  return api;          } -        if (api != 0) +        if (api != 0) { +                LOG_INFO("Instantiated %s as AP-i %d.", argv[0], api);                  return api; +        }          execv(argv[0], argv); @@ -1363,7 +1364,8 @@ static struct irm_flow * flow_req_arr(pid_t  api,                  pthread_mutex_lock(&re->state_lock);                  re->state = REG_NAME_AUTO_EXEC; -                a = apn_table_get(&irmd->apn_table, reg_entry_get_apn(re)); +                a = apn_table_get_by_apn(&irmd->apn_table, +                                         reg_entry_get_apn(re));                  pthread_mutex_unlock(&re->state_lock);                  if (a == NULL || (c_api->pid = auto_execute(a->argv)) < 0) {                          pthread_mutex_lock(&re->state_lock); @@ -1595,6 +1597,9 @@ static void irm_destroy()          close(irmd->sockfd); +        if (unlink(IRM_SOCK_PATH)) +                LOG_DBG("Failed to unlink %s.", IRM_SOCK_PATH); +          pthread_rwlock_unlock(&irmd->state_lock);          pthread_rwlock_destroy(&irmd->reg_lock); @@ -1650,9 +1655,9 @@ void * irm_sanitize()                  list_for_each_safe(p, h, &irmd->spawned_apis) {                          struct pid_el * e = list_entry(p, struct pid_el, next); +                        waitpid(e->pid, &s, WNOHANG);                          if (kill(e->pid, 0) >= 0)                                  continue; -                        waitpid(e->pid, &s, WNOHANG);                          LOG_DBG("Child process %d died, error %d.", e->pid, s);                          list_del(&e->next);                          free(e); @@ -1690,8 +1695,7 @@ void * irm_sanitize()                                          continue;                                  LOG_DBG("Dead AP-I removed from: %d %s.",                                          a->pid, e->name); -                                list_del(&a->next); -                                free(a); +                                reg_entry_del_api(e, a->pid);                          }                  } | 
