diff options
author | dimitri staessens <[email protected]> | 2017-02-21 21:33:25 +0000 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2017-02-21 21:33:25 +0000 |
commit | ef0f04e9631947e8419f23743dd20cd538c04473 (patch) | |
tree | c16a4a1c829862363cd826a5a256b993b18de2bc /src/irmd/main.c | |
parent | 51adb17f46dc675456d5426b45d445082816ce5c (diff) | |
parent | ffe3262f5e78d67aa6b4214f0533ed8ada913442 (diff) | |
download | ouroboros-ef0f04e9631947e8419f23743dd20cd538c04473.tar.gz ouroboros-ef0f04e9631947e8419f23743dd20cd538c04473.zip |
Merged in dstaesse/ouroboros/be-irmd (pull request #386)
irmd: Fix detection of IRMd
Diffstat (limited to 'src/irmd/main.c')
-rw-r--r-- | src/irmd/main.c | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/src/irmd/main.c b/src/irmd/main.c index 7f20faf4..e1071920 100644 --- a/src/irmd/main.c +++ b/src/irmd/main.c @@ -2048,6 +2048,28 @@ static int irm_create(void) return -ENOMEM; } + if ((irmd->lf = lockfile_create()) == NULL) { + if ((irmd->lf = lockfile_open()) == NULL) { + log_err("Lockfile error."); + irm_destroy(); + return -1; + } + + if (kill(lockfile_owner(irmd->lf), 0) < 0) { + log_info("IRMd didn't properly shut down last time."); + shm_rdrbuff_destroy(shm_rdrbuff_open()); + log_info("Stale resources cleaned."); + lockfile_destroy(irmd->lf); + irmd->lf = lockfile_create(); + } else { + log_info("IRMd already running (%d), exiting.", + lockfile_owner(irmd->lf)); + lockfile_close(irmd->lf); + free(irmd); + return -1; + } + } + if (stat(SOCK_PATH, &st) == -1) { if (mkdir(SOCK_PATH, 0777)) { log_err("Failed to create sockets directory."); @@ -2075,28 +2097,6 @@ static int irm_create(void) return -1; } - if ((irmd->lf = lockfile_create()) == NULL) { - if ((irmd->lf = lockfile_open()) == NULL) { - log_err("Lockfile error."); - irm_destroy(); - return -1; - } - - if (kill(lockfile_owner(irmd->lf), 0) < 0) { - log_info("IRMd didn't properly shut down last time."); - shm_rdrbuff_destroy(shm_rdrbuff_open()); - log_info("Stale resources cleaned."); - lockfile_destroy(irmd->lf); - irmd->lf = lockfile_create(); - } else { - log_info("IRMd already running (%d), exiting.", - lockfile_owner(irmd->lf)); - lockfile_close(irmd->lf); - free(irmd); - return -1; - } - } - if (irmd->lf == NULL) { irm_destroy(); return -1; |