mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-27 23:55:57 -05:00
Maintain libhash in the conffile module
This commit is contained in:
parent
27acda871a
commit
e3fb8f00cf
@ -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;
|
||||
|
@ -7,6 +7,7 @@
|
||||
#define CONFFILE CONFDIR "/forked-daapd.conf"
|
||||
|
||||
extern cfg_t *cfg;
|
||||
extern uint64_t libhash;
|
||||
|
||||
int
|
||||
conffile_load(char *file);
|
||||
|
@ -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");
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user