diff --git a/src/conffile.c b/src/conffile.c index 57436479..88bb2968 100644 --- a/src/conffile.c +++ b/src/conffile.c @@ -23,6 +23,7 @@ #include #include #include +#include #include @@ -31,6 +32,7 @@ #include #include "logger.h" +#include "misc.h" #include "conffile.h" @@ -71,6 +73,7 @@ static cfg_opt_t toplvl_cfg[] = }; cfg_t *cfg; +uint64_t libhash; static int @@ -114,11 +117,15 @@ conffile_expand_libname(cfg_t *lib) int ret; libname = cfg_getstr(lib, "name"); + olen = strlen(libname); /* Fast path */ s = strchr(libname, '%'); if (!s) - return 0; + { + libhash = murmur_hash64(libname, olen, 0); + return 0; + } /* Grab what we need */ ret = uname(&sysinfo); @@ -133,10 +140,8 @@ conffile_expand_libname(cfg_t *lib) hostlen = strlen(hostname); verlen = strlen(VERSION); - olen = strlen(libname); - len = olen; - /* Compute expanded size */ + len = olen; s = libname; while (*s) { @@ -202,6 +207,8 @@ conffile_expand_libname(cfg_t *lib) cfg_setstr(lib, "name", expanded); + libhash = murmur_hash64(expanded, strlen(expanded), 0); + free(expanded); return 0; diff --git a/src/conffile.h b/src/conffile.h index 87e28b30..b531a603 100644 --- a/src/conffile.h +++ b/src/conffile.h @@ -7,6 +7,7 @@ #define CONFFILE CONFDIR "/forked-daapd.conf" extern cfg_t *cfg; +extern uint64_t libhash; int conffile_load(char *file); diff --git a/src/main.c b/src/main.c index 6e495b4f..89fa9f1a 100644 --- a/src/main.c +++ b/src/main.c @@ -236,7 +236,6 @@ register_services(char *ffid, int no_rsp, int no_daap) char records[9][128]; int port; uint32_t hash; - uint64_t libhash; int i; int ret; @@ -301,8 +300,6 @@ register_services(char *ffid, int no_rsp, int no_daap) memset(records[i], 0, 128); } - libhash = murmur_hash64(libname, strlen(libname), 0); - snprintf(txtrecord[0], 128, "txtvers=1"); snprintf(txtrecord[1], 128, "DbId=%016" PRIX64, libhash); snprintf(txtrecord[2], 128, "DvTy=iTunes"); diff --git a/src/remote_pairing.c b/src/remote_pairing.c index ebe1530f..4b753068 100644 --- a/src/remote_pairing.c +++ b/src/remote_pairing.c @@ -86,7 +86,6 @@ static int pairing_pipe[2]; static struct event pairingev; static pthread_mutex_t remote_lck = PTHREAD_MUTEX_INITIALIZER; static struct remote_info *remote_list; -static uint64_t libhash; /* iTunes - Remote pairing hash */ @@ -775,7 +774,6 @@ pairing_cb(int fd, short event, void *arg) int remote_pairing_init(void) { - char *libname; int ret; remote_list = NULL; @@ -820,9 +818,6 @@ remote_pairing_init(void) goto mdns_browse_fail; } - libname = cfg_getstr(cfg_getsec(cfg, "library"), "name"); - libhash = murmur_hash64(libname, strlen(libname), 0); - #ifdef USE_EVENTFD event_set(&pairingev, pairing_efd, EV_READ, pairing_cb, NULL); #else