]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Allow building without semaphores
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 5 May 2022 14:14:50 +0000 (16:14 +0200)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sat, 7 May 2022 22:27:12 +0000 (17:27 -0500)
src/lib/server/main_config.c
src/lib/util/sem.h

index 3b01f53d4edb7d303da271965fc6e44503af1222..25687f410d3cc6837f8b1eca11e9477563c81644 100644 (file)
@@ -827,9 +827,15 @@ void main_config_raddb_dir_set(main_config_t *config, char const *name)
  * 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
@@ -839,9 +845,17 @@ void main_config_exclusive_proc_done(main_config_t const *config)
  *     - 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)
@@ -855,8 +869,12 @@ int main_config_exclusive_proc_child(main_config_t const *config)
 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;
 
@@ -874,6 +892,8 @@ int main_config_exclusive_proc(main_config_t *config)
        }  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(),
@@ -909,8 +929,8 @@ int main_config_exclusive_proc(main_config_t *config)
                talloc_free(path);
                break;
        }
-
 done:
+#endif
        if (fp != NULL) fclose(fp);
 
        return ret;
index 610bad20fe6df3cfc814b997eb18e7901b26e0a0..a89712d8ca126423874ad3b0b2b6e1d4bbfd35ae 100644 (file)
  */
 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);
@@ -48,8 +50,9 @@ int   fr_sem_wait(int sem_id, char const *file, bool undo_on_exit, bool nonblock);
 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
+