From 04a8f3ceedefa63f9344311e5ff05ab3ce754fda Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Thu, 7 Jul 2016 15:12:42 +0200 Subject: lib: Add lockfile The pid of the IRMd is stored in a lockfile in shared memory. This makes checking if the IRMd is running independent of the configuration, as previously the IRMd pid was stored at the end of the shm_du_map, which could not be read by an IRMd that would be compiled with different configuration options. Also corrects some unnecessary includes Fixes #21. --- src/lib/shm_ap_rbuff.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/lib/shm_ap_rbuff.c') diff --git a/src/lib/shm_ap_rbuff.c b/src/lib/shm_ap_rbuff.c index 4eb91136..cf795601 100644 --- a/src/lib/shm_ap_rbuff.c +++ b/src/lib/shm_ap_rbuff.c @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include @@ -215,7 +215,7 @@ void shm_ap_rbuff_close(struct shm_ap_rbuff * rb) void shm_ap_rbuff_destroy(struct shm_ap_rbuff * rb) { char fn[25]; - struct shm_du_map * dum = NULL; + struct lockfile * lf = NULL; if (rb == NULL) { LOG_DBGF("Bogus input. Bugging out."); @@ -223,15 +223,17 @@ void shm_ap_rbuff_destroy(struct shm_ap_rbuff * rb) } if (rb->api != getpid()) { - dum = shm_du_map_open(); - if (shm_du_map_owner(dum) == getpid()) { + lf = lockfile_open(); + if (lf == NULL) + return; + if (lockfile_owner(lf) == getpid()) { LOG_DBGF("Ringbuffer %d destroyed by IRMd %d.", rb->api, getpid()); - shm_du_map_close(dum); + lockfile_close(lf); } else { LOG_ERR("AP-I %d tried to destroy rbuff owned by %d.", getpid(), rb->api); - shm_du_map_close(dum); + lockfile_close(lf); return; } } -- cgit v1.2.3 From b3870ef695a256be4a4ed28a991c39aab37bd6f3 Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Thu, 7 Jul 2016 15:37:34 +0200 Subject: ouroboros: Use ouroboros errno.h All includes of within ouroboros are replaced with the ouroboros errno. --- src/ipcpd/local/main.c | 2 +- src/ipcpd/normal/shm_pci.c | 3 ++- src/ipcpd/shim-eth-llc/main.c | 2 +- src/irmd/main.c | 2 +- src/irmd/registry.c | 2 +- src/lib/ipcp.c | 2 +- src/lib/shm_ap_rbuff.c | 2 +- src/lib/shm_du_map.c | 2 +- src/lib/sockets.c | 2 +- src/tools/irm/irm_bind.c | 2 +- 10 files changed, 11 insertions(+), 10 deletions(-) (limited to 'src/lib/shm_ap_rbuff.c') diff --git a/src/ipcpd/local/main.c b/src/ipcpd/local/main.c index fee7fd22..d72269b8 100644 --- a/src/ipcpd/local/main.c +++ b/src/ipcpd/local/main.c @@ -23,6 +23,7 @@ #include #include "ipcp.h" #include "flow.h" +#include #include #include #include @@ -38,7 +39,6 @@ #include -#include #include #include #include diff --git a/src/ipcpd/normal/shm_pci.c b/src/ipcpd/normal/shm_pci.c index e76d8009..144bd15e 100644 --- a/src/ipcpd/normal/shm_pci.c +++ b/src/ipcpd/normal/shm_pci.c @@ -21,9 +21,10 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include + #include "shm_pci.h" #include -#include #define SHM_PCI_HEAD_SIZE(a, b) a.addr_size * 2 + \ a.cep_id_size * 2 + \ diff --git a/src/ipcpd/shim-eth-llc/main.c b/src/ipcpd/shim-eth-llc/main.c index 4c260301..f82438c6 100644 --- a/src/ipcpd/shim-eth-llc/main.c +++ b/src/ipcpd/shim-eth-llc/main.c @@ -26,6 +26,7 @@ #include "ipcp.h" #include "flow.h" +#include #include #include #include @@ -47,7 +48,6 @@ #include #include #include -#include #include #include #include diff --git a/src/irmd/main.c b/src/irmd/main.c index c1481a67..19bc5b9b 100644 --- a/src/irmd/main.c +++ b/src/irmd/main.c @@ -24,6 +24,7 @@ #define OUROBOROS_PREFIX "irmd" #include +#include #include #include #include @@ -46,7 +47,6 @@ #include #include #include -#include #include #include #include diff --git a/src/irmd/registry.c b/src/irmd/registry.c index ae532d5a..c5f81d77 100644 --- a/src/irmd/registry.c +++ b/src/irmd/registry.c @@ -26,13 +26,13 @@ #define OUROBOROS_PREFIX "registry" +#include #include #include #include #include #include -#include struct reg_instance * reg_instance_create(pid_t api) { diff --git a/src/lib/ipcp.c b/src/lib/ipcp.c index 5d46940d..b0e593e4 100644 --- a/src/lib/ipcp.c +++ b/src/lib/ipcp.c @@ -23,6 +23,7 @@ #define OUROBOROS_PREFIX "lib-ipcp" #include +#include #include #include #include @@ -32,7 +33,6 @@ #include #include #include -#include #include #include #include diff --git a/src/lib/shm_ap_rbuff.c b/src/lib/shm_ap_rbuff.c index cf795601..618c4c19 100644 --- a/src/lib/shm_ap_rbuff.c +++ b/src/lib/shm_ap_rbuff.c @@ -21,6 +21,7 @@ */ #include +#include #define OUROBOROS_PREFIX "shm_ap_rbuff" @@ -35,7 +36,6 @@ #include #include #include -#include #include #include diff --git a/src/lib/shm_du_map.c b/src/lib/shm_du_map.c index 01d1e23d..6a4b7361 100644 --- a/src/lib/shm_du_map.c +++ b/src/lib/shm_du_map.c @@ -22,6 +22,7 @@ */ #include +#include #include #include #include @@ -33,7 +34,6 @@ #include #include #include -#include #include #define OUROBOROS_PREFIX "shm_du_map" diff --git a/src/lib/sockets.c b/src/lib/sockets.c index d60ea91a..9e13b687 100644 --- a/src/lib/sockets.c +++ b/src/lib/sockets.c @@ -23,6 +23,7 @@ #define OUROBOROS_PREFIX "libouroboros-sockets" #include +#include #include #include #include @@ -32,7 +33,6 @@ #include #include #include -#include int client_socket_open(char * file_name) { diff --git a/src/tools/irm/irm_bind.c b/src/tools/irm/irm_bind.c index 45da6e4c..061aeef5 100644 --- a/src/tools/irm/irm_bind.c +++ b/src/tools/irm/irm_bind.c @@ -22,9 +22,9 @@ #include #include -#include #include +#include #include "irm_ops.h" #include "irm_utils.h" -- cgit v1.2.3