diff options
author | Sander Vrijders <[email protected]> | 2017-08-29 18:34:26 +0200 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2017-08-29 18:34:26 +0200 |
commit | 7d598d4a706e06e7e89218ca9ae071dd630cb2b3 (patch) | |
tree | a533c39bd42c9cbdb482ff210378b797c77b9e6e | |
parent | 706de5704f4d61929bbbb87d8d667ba68fcffc7d (diff) | |
download | ouroboros-7d598d4a706e06e7e89218ca9ae071dd630cb2b3.tar.gz ouroboros-7d598d4a706e06e7e89218ca9ae071dd630cb2b3.zip |
irmd: Fix deleting corrupt shm file
This will delete the rdrbuff also when it has been corrupted
before. Otherwise the irmd won't start, as experienced on my desktop.
-rw-r--r-- | include/ouroboros/shm_rdrbuff.h | 2 | ||||
-rw-r--r-- | src/irmd/main.c | 2 | ||||
-rw-r--r-- | src/lib/shm_rdrbuff.c | 12 |
3 files changed, 15 insertions, 1 deletions
diff --git a/include/ouroboros/shm_rdrbuff.h b/include/ouroboros/shm_rdrbuff.h index 079c11b2..29410ac3 100644 --- a/include/ouroboros/shm_rdrbuff.h +++ b/include/ouroboros/shm_rdrbuff.h @@ -41,6 +41,8 @@ void shm_rdrbuff_close(struct shm_rdrbuff * rdrb); void shm_rdrbuff_destroy(struct shm_rdrbuff * rdrb); +void shm_rdrbuff_purge(void); + int shm_rdrbuff_wait_full(struct shm_rdrbuff * rdrb, struct timespec * timeo); diff --git a/src/irmd/main.c b/src/irmd/main.c index 1d62de85..c5caff6c 100644 --- a/src/irmd/main.c +++ b/src/irmd/main.c @@ -2204,7 +2204,7 @@ static int irm_init(void) if (kill(lockfile_owner(irmd.lf), 0) < 0) { log_info("IRMd didn't properly shut down last time."); - shm_rdrbuff_destroy(shm_rdrbuff_open()); + shm_rdrbuff_purge(); log_info("Stale resources cleaned."); lockfile_destroy(irmd.lf); irmd.lf = lockfile_create(); diff --git a/src/lib/shm_rdrbuff.c b/src/lib/shm_rdrbuff.c index d8893677..a3333a35 100644 --- a/src/lib/shm_rdrbuff.c +++ b/src/lib/shm_rdrbuff.c @@ -323,6 +323,18 @@ void shm_rdrbuff_close(struct shm_rdrbuff * rdrb) free(rdrb); } +void shm_rdrbuff_purge(void) +{ + char * shm_rdrb_fn; + + shm_rdrb_fn = rdrb_filename(); + if (shm_rdrb_fn == NULL) + return; + + shm_unlink(shm_rdrb_fn); + free(shm_rdrb_fn); +} + void shm_rdrbuff_destroy(struct shm_rdrbuff * rdrb) { char * shm_rdrb_fn; |