From 346b054ee32a9f7b8491f842709f72cc8d1f3f2e Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Mon, 27 Nov 2023 14:43:11 +0100 Subject: include: Store IPCP name and type in info struct The information for an IPCP is now stored in an ipcp_info struct, containing name and type. The IRM public API is not changed. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/irmd/reg/ipcp.c | 11 ++--------- src/irmd/reg/ipcp.h | 7 +++---- 2 files changed, 5 insertions(+), 13 deletions(-) (limited to 'src/irmd/reg') diff --git a/src/irmd/reg/ipcp.c b/src/irmd/reg/ipcp.c index 62505871..f64bb5a4 100644 --- a/src/irmd/reg/ipcp.c +++ b/src/irmd/reg/ipcp.c @@ -42,8 +42,7 @@ #include #include -struct reg_ipcp * reg_ipcp_create(const char * name, - enum ipcp_type type) +struct reg_ipcp * reg_ipcp_create(const struct ipcp_info * info) { struct reg_ipcp * ipcp; pthread_condattr_t cattr; @@ -63,22 +62,17 @@ struct reg_ipcp * reg_ipcp_create(const char * name, if (pthread_cond_init(&ipcp->cond, &cattr)) goto fail_cond; - ipcp->name = strdup(name); - if (ipcp->name == NULL) - goto fail_name; + memcpy(&ipcp->info, info, sizeof(*info)); pthread_condattr_destroy(&cattr); ipcp->layer = NULL; - ipcp->type = type; ipcp->state = IPCP_BOOT; list_head_init(&ipcp->next); return ipcp; - fail_name: - pthread_cond_destroy(&ipcp->cond); fail_cond: pthread_condattr_destroy(&cattr); fail_cattr: @@ -99,7 +93,6 @@ void reg_ipcp_destroy(struct reg_ipcp * ipcp) pthread_cond_wait(&ipcp->cond, &ipcp->mtx); free(ipcp->layer); - free(ipcp->name); pthread_mutex_unlock(&ipcp->mtx); diff --git a/src/irmd/reg/ipcp.h b/src/irmd/reg/ipcp.h index 8ad334cf..3757aff4 100644 --- a/src/irmd/reg/ipcp.h +++ b/src/irmd/reg/ipcp.h @@ -34,9 +34,9 @@ enum ipcp_state { struct reg_ipcp { struct list_head next; - char * name; + struct ipcp_info info; + pid_t pid; - enum ipcp_type type; enum hash_algo dir_hash_algo; char * layer; @@ -45,8 +45,7 @@ struct reg_ipcp { pthread_mutex_t mtx; }; -struct reg_ipcp * reg_ipcp_create(const char * name, - enum ipcp_type type); +struct reg_ipcp * reg_ipcp_create(const struct ipcp_info * info); void reg_ipcp_destroy(struct reg_ipcp * i); -- cgit v1.2.3