diff options
author | dimitri staessens <[email protected]> | 2016-08-29 19:49:39 +0200 |
---|---|---|
committer | dimitri staessens <[email protected]> | 2016-08-29 20:32:54 +0200 |
commit | 2cc89f6da424ab503af563e0cc92dda43b8f8432 (patch) | |
tree | 303d3d61717d4d3018b8025a9825ff799da01c08 /src/ipcpd/normal | |
parent | caeefb4d96331d24b38e845c99d0517913a71671 (diff) | |
download | ouroboros-2cc89f6da424ab503af563e0cc92dda43b8f8432.tar.gz ouroboros-2cc89f6da424ab503af563e0cc92dda43b8f8432.zip |
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.
Diffstat (limited to 'src/ipcpd/normal')
-rw-r--r-- | src/ipcpd/normal/main.c | 20 |
1 files changed, 13 insertions, 7 deletions
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 <ouroboros/config.h> #include <ouroboros/logs.h> -#include <ouroboros/shm_du_map.h> +#include <ouroboros/shm_rdrbuff.h> #include <ouroboros/shm_ap_rbuff.h> #include <ouroboros/dev.h> #include <ouroboros/ipcp.h> @@ -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); |