summaryrefslogtreecommitdiff
path: root/src/lib/shm_ap_rbuff.c
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@intec.ugent.be>2016-07-07 15:44:16 +0200
committerSander Vrijders <sander.vrijders@intec.ugent.be>2016-07-07 15:44:16 +0200
commitcc377e56c6fd25403fc7ccf5f83c82e3d85a767b (patch)
tree33604c48880d3a01d7053608584236dd15fc43e8 /src/lib/shm_ap_rbuff.c
parent80441117cf61137c6a8c97e0779e70d76ae8541d (diff)
parentb3870ef695a256be4a4ed28a991c39aab37bd6f3 (diff)
downloadouroboros-cc377e56c6fd25403fc7ccf5f83c82e3d85a767b.tar.gz
ouroboros-cc377e56c6fd25403fc7ccf5f83c82e3d85a767b.zip
Merged in dstaesse/ouroboros/be-lockfile (pull request #165)
lib: Add lockfile
Diffstat (limited to 'src/lib/shm_ap_rbuff.c')
-rw-r--r--src/lib/shm_ap_rbuff.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/lib/shm_ap_rbuff.c b/src/lib/shm_ap_rbuff.c
index 4eb91136..618c4c19 100644
--- a/src/lib/shm_ap_rbuff.c
+++ b/src/lib/shm_ap_rbuff.c
@@ -21,12 +21,13 @@
*/
#include <ouroboros/config.h>
+#include <ouroboros/errno.h>
#define OUROBOROS_PREFIX "shm_ap_rbuff"
#include <ouroboros/logs.h>
#include <ouroboros/shm_ap_rbuff.h>
-#include <ouroboros/shm_du_map.h>
+#include <ouroboros/lockfile.h>
#include <pthread.h>
#include <sys/mman.h>
@@ -35,7 +36,6 @@
#include <string.h>
#include <stdint.h>
#include <unistd.h>
-#include <errno.h>
#include <signal.h>
#include <sys/stat.h>
@@ -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;
}
}