]> git.tuebingen.mpg.de Git - dss.git/blobdiff - ipc.c
Merge topic branch t/realpath into pu
[dss.git] / ipc.c
diff --git a/ipc.c b/ipc.c
index 4aef302604cb1d80c65839148ece4372d48f6f99..e6ec79e062cf2543f8159d6bcf390cdb872438c6 100644 (file)
--- a/ipc.c
+++ b/ipc.c
@@ -35,7 +35,7 @@
  * SuperFastHash, by Paul Hsieh.
  * http://www.azillionmonkeys.com/qed/hash.html
  */
-static uint32_t super_fast_hash(const uint8_t *data, uint32_t len, uint32_t hash)
+uint32_t super_fast_hash(const uint8_t *data, uint32_t len, uint32_t hash)
 {
        uint32_t tmp;
        int rem = len & 3;
@@ -78,35 +78,6 @@ static uint32_t super_fast_hash(const uint8_t *data, uint32_t len, uint32_t hash
        return hash;
 }
 
-static int get_key_or_die(const char *config_file)
-{
-       int ret;
-       struct stat statbuf;
-       char *rpath;
-
-       assert(config_file);
-       if (stat(config_file, &statbuf) == 0) {
-               rpath = realpath(config_file, NULL);
-               if (!rpath) {
-                       DSS_EMERG_LOG(("could not resolve path %s: %m\n", config_file));
-                       exit(EXIT_FAILURE);
-               }
-               DSS_DEBUG_LOG(("resolved path: %s\n", rpath));
-       } else
-               /*
-                * This happens if the user did not specify a config file, and
-                * the default config file does not exist.  Another (unlikely)
-                * possibility is that the config file was removed between
-                * startup and this call. We don't care about these corner
-                * cases too much and just use the unresolved path in this
-                * case.
-                */
-               rpath = dss_strdup(config_file);
-       ret = super_fast_hash((uint8_t *)rpath, strlen(rpath), 0) >> 1;
-       free(rpath);
-       return ret;
-}
-
 static int mutex_get(key_t key, int flags)
 {
        int ret;
@@ -148,11 +119,10 @@ static bool mutex_is_locked(int id)
        return false;
 }
 
-int lock_dss(char *config_file)
+int lock_dss(uint32_t key)
 {
        int ret, id;
        struct sembuf sops[4];
-       key_t key = get_key_or_die(config_file);
 
        ret = mutex_get(key, IPC_CREAT | 0600);
        if (ret < 0)
@@ -178,10 +148,9 @@ int lock_dss(char *config_file)
        return do_semop(id, sops, 4);
 }
 
-int get_dss_pid(char *config_file, pid_t *pid)
+int get_dss_pid(uint32_t key, pid_t *pid)
 {
        int ret, semid;
-       key_t key = get_key_or_die(config_file);
 
        if (pid)
                *pid = 0;