From 2cc89f6da424ab503af563e0cc92dda43b8f8432 Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Mon, 29 Aug 2016 19:49:39 +0200 Subject: lib: Refactor shm_du_map to shm_rdrbuff The shm_du_map is renamed to shm_rdrbuff to reflect the Random Deletion Ringbuffer used in the implementation. The close_on_exit call is removed and SDUs are cleaned up by the application in the ap_fini() call. This required a non-blocking peek() operation in the shm_ap_rbuff. Some initial implementation for future support of qos cubes has been added to the shm_rdrbuff. --- src/ipcpd/normal/main.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src/ipcpd/normal/main.c') diff --git a/src/ipcpd/normal/main.c b/src/ipcpd/normal/main.c index 335330ae..cf4ae3f1 100644 --- a/src/ipcpd/normal/main.c +++ b/src/ipcpd/normal/main.c @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include #include @@ -55,7 +55,7 @@ struct normal_ipcp_data { /* Keep ipcp_data first for polymorphism. */ struct ipcp_data ipcp_data; - struct shm_du_map * dum; + struct shm_rdrbuff * rdrb; struct shm_ap_rbuff * rb; pthread_t mainloop; @@ -206,15 +206,15 @@ struct normal_ipcp_data * normal_ipcp_data_create() return NULL; } - normal_data->dum = shm_du_map_open(); - if (normal_data->dum == NULL) { + normal_data->rdrb = shm_rdrbuff_open(); + if (normal_data->rdrb == NULL) { free(normal_data); return NULL; } normal_data->rb = shm_ap_rbuff_open(getpid()); if (normal_data->rb == NULL) { - shm_du_map_close(normal_data->dum); + shm_rdrbuff_close(normal_data->rdrb); free(normal_data); return NULL; } @@ -225,6 +225,8 @@ struct normal_ipcp_data * normal_ipcp_data_create() void normal_ipcp_data_destroy() { + int idx = 0; + if (_ipcp == NULL) return; @@ -233,8 +235,12 @@ void normal_ipcp_data_destroy() if (ipcp_get_state(_ipcp) != IPCP_SHUTDOWN) LOG_WARN("Cleaning up while not in shutdown."); - if (normal_data(_ipcp)->dum != NULL) - shm_du_map_close_on_exit(normal_data(_ipcp)->dum); + /* remove all remaining sdus */ + while ((idx = shm_ap_rbuff_peek_idx(normal_data(_ipcp)->rb)) >= 0) + shm_rdrbuff_remove(normal_data(_ipcp)->rdrb, idx); + + if (normal_data(_ipcp)->rdrb != NULL) + shm_rdrbuff_close(normal_data(_ipcp)->rdrb); if (normal_data(_ipcp)->rb != NULL) shm_ap_rbuff_close(normal_data(_ipcp)->rb); -- cgit v1.2.3