* running the process under something like systemd and running it under
* debug mode.
*/
-void main_config_exclusive_proc_done(main_config_t const *config)
+void main_config_exclusive_proc_done(
+#ifndef HAVE_SEMAPHORES
+ UNUSED
+#endif
+ main_config_t const *config)
{
+#ifdef HAVE_SEMAPHORES
if (config->multi_proc_sem_id >= 0) fr_sem_close(config->multi_proc_sem_id, NULL);
+#endif
}
/** Increment the semaphore in the child process so that it's not released when the parent exits
* - 0 on success.
* - -1 on failure.
*/
-int main_config_exclusive_proc_child(main_config_t const *config)
+int main_config_exclusive_proc_child(
+#ifndef HAVE_SEMAPHORES
+ UNUSED
+#endif
+ main_config_t const *config)
{
+#ifdef HAVE_SEMAPHORES
return fr_sem_take(config->multi_proc_sem_id, config->multi_proc_sem_path, true);
+#else
+ return 0;
+#endif
}
/** Check to see if we're the only process using this configuration file (or PID file if specified)
int main_config_exclusive_proc(main_config_t *config)
{
char *path;
+
+#ifdef HAVE_SEMAPHORES
int sem_id;
- int ret;
+#endif
+
+ int ret = 0;
FILE *fp = NULL;
static bool sem_initd;
} else {
MEM(path = talloc_asprintf(config, "%s/%s.conf", config->raddb_dir, config->name));
}
+
+#ifdef HAVE_SEMAPHORES
sem_id = fr_sem_get(path, 0,
main_config->uid_is_set ? main_config->uid : geteuid(),
main_config->gid_is_set ? main_config->gid : getegid(),
talloc_free(path);
break;
}
-
done:
+#endif
if (fp != NULL) fclose(fp);
return ret;
*/
RCSIDH(sem_h, "$Id$")
-#ifndef __EMSCRIPTEN__
#ifdef __cplusplus
extern "C" {
#endif
+#ifndef __EMSCRIPTEN__
+#define HAVE_SEMAPHORES
+
int fr_sem_pid(pid_t *pid, int sem_id);
int fr_sem_uid(uid_t *uid, int sem_id);
int fr_sem_close(int sem_id, char const *file);
int fr_sem_get(char const *file, int proj_id, uid_t uid, gid_t gid, bool check_perm, bool must_exist);
+#endif
#ifdef __cplusplus
}
#endif
-#endif
+