diff options
author | Sander Vrijders <sander.vrijders@intec.ugent.be> | 2016-07-29 14:05:11 +0200 |
---|---|---|
committer | Sander Vrijders <sander.vrijders@intec.ugent.be> | 2016-07-29 14:05:11 +0200 |
commit | 434c782c99496b491684f4ab0058d9491c250774 (patch) | |
tree | afcfd1cb6399811f2275a7ebfc345f8e3f3afd27 /src/irmd | |
parent | 2d529f912c089033e2f40fd0978ccb741bfe2bbb (diff) | |
parent | ce401448d62f65956ed57b077af2b315f59efe94 (diff) | |
download | ouroboros-434c782c99496b491684f4ab0058d9491c250774.tar.gz ouroboros-434c782c99496b491684f4ab0058d9491c250774.zip |
Merged in dstaesse/ouroboros/be-bsd (pull request #181)
build: FreeBSD compatibility
Diffstat (limited to 'src/irmd')
-rw-r--r-- | src/irmd/main.c | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/src/irmd/main.c b/src/irmd/main.c index b071ff1c..1c731788 100644 --- a/src/irmd/main.c +++ b/src/irmd/main.c @@ -1679,28 +1679,6 @@ static struct irm * irm_create() irmd->state = IRMD_NULL; - if (access("/dev/shm/" LOCKFILE_NAME, F_OK) != -1) { - struct lockfile * lf = lockfile_open(); - if (lf == NULL) { - LOG_ERR("Failed to open existing lockfile."); - free(irmd); - return NULL; - } - - if (kill(lockfile_owner(lf), 0) < 0) { - LOG_INFO("IRMd didn't properly shut down last time."); - shm_du_map_destroy(shm_du_map_open()); - LOG_INFO("Stale resources cleaned"); - lockfile_destroy(lf); - } else { - LOG_INFO("IRMd already running (%d), exiting.", - lockfile_owner(lf)); - lockfile_close(lf); - free(irmd); - return NULL; - } - } - if (pthread_rwlock_init(&irmd->state_lock, NULL)) { LOG_ERR("Failed to initialize rwlock."); free(irmd); @@ -1757,6 +1735,28 @@ static struct irm * irm_create() } if ((irmd->lf = lockfile_create()) == NULL) { + if ((irmd->lf = lockfile_open()) == NULL) { + LOG_ERR("Lockfile error."); + irm_destroy(); + return NULL; + } + + if (kill(lockfile_owner(irmd->lf), 0) < 0) { + LOG_INFO("IRMd didn't properly shut down last time."); + shm_du_map_destroy(shm_du_map_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 NULL; + } + } + + if (irmd->lf == NULL) { irm_destroy(); return NULL; } @@ -1768,6 +1768,8 @@ static struct irm * irm_create() irmd->state = IRMD_RUNNING; + LOG_INFO("IRMd started..."); + return irmd; } |