Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Maintain libhash in the conffile module

  • Loading branch information...
commit e3fb8f00cf4192a5e44c46c973964ea937bf4759 1 parent 27acda8
Julien BLACHE authored
View
15 src/conffile.c
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
+#include <stdint.h>
#include <sys/utsname.h>
@@ -31,6 +32,7 @@
#include <confuse.h>
#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;
View
1  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);
View
3  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");
View
5 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
Please sign in to comment.
Something went wrong with that request. Please try again.