don't rescan the database if nobody is connected

This commit is contained in:
Ron Pedde
2004-10-25 04:50:59 +00:00
parent 040421a5e3
commit 0beb5c10d3
3 changed files with 35 additions and 16 deletions

View File

@@ -52,8 +52,12 @@
#include "dynamic-art.h"
#ifndef DEFAULT_CONFIGFILE
#ifdef NSLU2
#define DEFAULT_CONFIGFILE "/opt/etc/mt-daapd.conf"
#else
#define DEFAULT_CONFIGFILE "/etc/mt-daapd.conf"
#endif
#endif
#ifndef PIDFILE
#define PIDFILE "/var/run/mt-daapd.pid"
@@ -483,7 +487,12 @@ int drop_privs(char *user) {
/* drop privs */
if(getuid() == (uid_t)0) {
pw=getpwnam(config.runas);
if(atoi(user)) {
pw=getpwuid((uid_t)atoi(user)); /* doh! */
} else {
pw=getpwnam(config.runas);
}
if(pw) {
if(initgroups(user,pw->pw_gid) != 0 ||
setgid(pw->pw_gid) != 0 ||
@@ -737,9 +746,10 @@ int main(int argc, char *argv[]) {
while(!config.stop) {
if((config.rescan_interval) && (rescan_counter > config.rescan_interval)) {
if(scan_init(config.mp3dir)) {
DPRINTF(ERR_LOG,"Background scanning error... exiting\n");
config.stop=1;
if((config.always_scan) || (config_get_session_count())) {
config.reload=1;
} else {
DPRINTF(ERR_DEBUG,"Skipping background scan... no connected users\n");
}
rescan_counter=0;
}
@@ -768,10 +778,6 @@ int main(int argc, char *argv[]) {
rend_stop();
}
/* Have a refcount problem with the web server...
* Need to troubleshoot it more later, but for now, we'll
* just stop the webserver the non-graceful way. */
DPRINTF(ERR_LOG,"Stopping web server\n");
ws_stop(server);