* 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;
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;
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)
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;