Make server abort when a shutdown signal happens during a playlist or xml scan

This commit is contained in:
Ron Pedde 2006-07-13 08:29:21 +00:00
parent 2ea83c6f2e
commit 581b8df5c7
4 changed files with 30 additions and 17 deletions

View File

@ -53,6 +53,7 @@
#include "mp3-scanner.h"
#include "os.h"
#include "restart.h"
#include "util.h"
/*
* Typedefs
@ -207,24 +208,26 @@ void scan_process_playlistlist(void) {
while(scan_playlistlist.next) {
pnext=scan_playlistlist.next;
DPRINTF(E_DBG,L_SCAN,"About to scan %s\n",pnext->path);
ext=pnext->path;
if(strrchr(pnext->path,'.')) {
ext = strrchr(pnext->path,'.');
}
file=pnext->path;
if(strrchr(pnext->path,PATHSEP)) {
file = strrchr(pnext->path,PATHSEP) + 1;
}
if(strcasecmp(file,"iTunes Music Library.xml") == 0) {
if(conf_get_int("scanning","process_xml",1)) {
DPRINTF(E_LOG,L_SCAN,"Scanning %s\n",pnext->path);
scan_xml_playlist(pnext->path);
if(!util_must_exit()) {
DPRINTF(E_DBG,L_SCAN,"About to scan %s\n",pnext->path);
ext=pnext->path;
if(strrchr(pnext->path,'.')) {
ext = strrchr(pnext->path,'.');
}
file=pnext->path;
if(strrchr(pnext->path,PATHSEP)) {
file = strrchr(pnext->path,PATHSEP) + 1;
}
if(strcasecmp(file,"iTunes Music Library.xml") == 0) {
if(conf_get_int("scanning","process_xml",1)) {
DPRINTF(E_LOG,L_SCAN,"Scanning %s\n",pnext->path);
scan_xml_playlist(pnext->path);
}
} else if(strcasecmp(ext,".m3u") == 0) {
scan_static_playlist(pnext->path);
}
} else if(strcasecmp(ext,".m3u") == 0) {
scan_static_playlist(pnext->path);
}
free(pnext->path);

View File

@ -39,6 +39,7 @@
#include "os.h"
#include "rxml.h"
#include "redblack.h"
#include "util.h"
/* Forwards */
int scan_xml_playlist(char *filename);
@ -479,6 +480,9 @@ int scan_xml_playlist(char *filename) {
void scan_xml_handler(int action,void* puser,char* info) {
static int state;
if(util_must_exit())
return;
switch(action) {
case RXML_EVT_OPEN: /* file opened */
state = XML_STATE_PREAMBLE;

View File

@ -14,6 +14,8 @@
#include <string.h>
#include <sys/types.h>
#include "daapd.h"
uint32_t util_djb_hash_block(unsigned char *data, uint32_t len) {
uint32_t hash = 5381;
unsigned char *pstr = data;
@ -33,3 +35,6 @@ uint32_t util_djb_hash_str(char *str) {
return util_djb_hash_block((unsigned char *)str,len);
}
int util_must_exit(void) {
return config.stop;
}

View File

@ -19,6 +19,7 @@
extern uint32_t util_djb_hash_block(unsigned char *data, uint32_t len);
extern uint32_t util_djb_hash_str(char *str);
extern int util_must_exit(void);
#endif /* _UTIL_H_ */