mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-29 08:33:23 -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 <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
|
|
||||||
@ -31,6 +32,7 @@
|
|||||||
#include <confuse.h>
|
#include <confuse.h>
|
||||||
|
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
#include "misc.h"
|
||||||
#include "conffile.h"
|
#include "conffile.h"
|
||||||
|
|
||||||
|
|
||||||
@ -71,6 +73,7 @@ static cfg_opt_t toplvl_cfg[] =
|
|||||||
};
|
};
|
||||||
|
|
||||||
cfg_t *cfg;
|
cfg_t *cfg;
|
||||||
|
uint64_t libhash;
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -114,11 +117,15 @@ conffile_expand_libname(cfg_t *lib)
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
libname = cfg_getstr(lib, "name");
|
libname = cfg_getstr(lib, "name");
|
||||||
|
olen = strlen(libname);
|
||||||
|
|
||||||
/* Fast path */
|
/* Fast path */
|
||||||
s = strchr(libname, '%');
|
s = strchr(libname, '%');
|
||||||
if (!s)
|
if (!s)
|
||||||
return 0;
|
{
|
||||||
|
libhash = murmur_hash64(libname, olen, 0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Grab what we need */
|
/* Grab what we need */
|
||||||
ret = uname(&sysinfo);
|
ret = uname(&sysinfo);
|
||||||
@ -133,10 +140,8 @@ conffile_expand_libname(cfg_t *lib)
|
|||||||
hostlen = strlen(hostname);
|
hostlen = strlen(hostname);
|
||||||
verlen = strlen(VERSION);
|
verlen = strlen(VERSION);
|
||||||
|
|
||||||
olen = strlen(libname);
|
|
||||||
len = olen;
|
|
||||||
|
|
||||||
/* Compute expanded size */
|
/* Compute expanded size */
|
||||||
|
len = olen;
|
||||||
s = libname;
|
s = libname;
|
||||||
while (*s)
|
while (*s)
|
||||||
{
|
{
|
||||||
@ -202,6 +207,8 @@ conffile_expand_libname(cfg_t *lib)
|
|||||||
|
|
||||||
cfg_setstr(lib, "name", expanded);
|
cfg_setstr(lib, "name", expanded);
|
||||||
|
|
||||||
|
libhash = murmur_hash64(expanded, strlen(expanded), 0);
|
||||||
|
|
||||||
free(expanded);
|
free(expanded);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#define CONFFILE CONFDIR "/forked-daapd.conf"
|
#define CONFFILE CONFDIR "/forked-daapd.conf"
|
||||||
|
|
||||||
extern cfg_t *cfg;
|
extern cfg_t *cfg;
|
||||||
|
extern uint64_t libhash;
|
||||||
|
|
||||||
int
|
int
|
||||||
conffile_load(char *file);
|
conffile_load(char *file);
|
||||||
|
@ -236,7 +236,6 @@ register_services(char *ffid, int no_rsp, int no_daap)
|
|||||||
char records[9][128];
|
char records[9][128];
|
||||||
int port;
|
int port;
|
||||||
uint32_t hash;
|
uint32_t hash;
|
||||||
uint64_t libhash;
|
|
||||||
int i;
|
int i;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -301,8 +300,6 @@ register_services(char *ffid, int no_rsp, int no_daap)
|
|||||||
memset(records[i], 0, 128);
|
memset(records[i], 0, 128);
|
||||||
}
|
}
|
||||||
|
|
||||||
libhash = murmur_hash64(libname, strlen(libname), 0);
|
|
||||||
|
|
||||||
snprintf(txtrecord[0], 128, "txtvers=1");
|
snprintf(txtrecord[0], 128, "txtvers=1");
|
||||||
snprintf(txtrecord[1], 128, "DbId=%016" PRIX64, libhash);
|
snprintf(txtrecord[1], 128, "DbId=%016" PRIX64, libhash);
|
||||||
snprintf(txtrecord[2], 128, "DvTy=iTunes");
|
snprintf(txtrecord[2], 128, "DvTy=iTunes");
|
||||||
|
@ -86,7 +86,6 @@ static int pairing_pipe[2];
|
|||||||
static struct event pairingev;
|
static struct event pairingev;
|
||||||
static pthread_mutex_t remote_lck = PTHREAD_MUTEX_INITIALIZER;
|
static pthread_mutex_t remote_lck = PTHREAD_MUTEX_INITIALIZER;
|
||||||
static struct remote_info *remote_list;
|
static struct remote_info *remote_list;
|
||||||
static uint64_t libhash;
|
|
||||||
|
|
||||||
|
|
||||||
/* iTunes - Remote pairing hash */
|
/* iTunes - Remote pairing hash */
|
||||||
@ -775,7 +774,6 @@ pairing_cb(int fd, short event, void *arg)
|
|||||||
int
|
int
|
||||||
remote_pairing_init(void)
|
remote_pairing_init(void)
|
||||||
{
|
{
|
||||||
char *libname;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
remote_list = NULL;
|
remote_list = NULL;
|
||||||
@ -820,9 +818,6 @@ remote_pairing_init(void)
|
|||||||
goto mdns_browse_fail;
|
goto mdns_browse_fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
libname = cfg_getstr(cfg_getsec(cfg, "library"), "name");
|
|
||||||
libhash = murmur_hash64(libname, strlen(libname), 0);
|
|
||||||
|
|
||||||
#ifdef USE_EVENTFD
|
#ifdef USE_EVENTFD
|
||||||
event_set(&pairingev, pairing_efd, EV_READ, pairing_cb, NULL);
|
event_set(&pairingev, pairing_efd, EV_READ, pairing_cb, NULL);
|
||||||
#else
|
#else
|
||||||
|
Loading…
Reference in New Issue
Block a user