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

View File

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

View File

@ -14,6 +14,8 @@
#include <string.h> #include <string.h>
#include <sys/types.h> #include <sys/types.h>
#include "daapd.h"
uint32_t util_djb_hash_block(unsigned char *data, uint32_t len) { uint32_t util_djb_hash_block(unsigned char *data, uint32_t len) {
uint32_t hash = 5381; uint32_t hash = 5381;
unsigned char *pstr = data; 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); 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_block(unsigned char *data, uint32_t len);
extern uint32_t util_djb_hash_str(char *str); extern uint32_t util_djb_hash_str(char *str);
extern int util_must_exit(void);
#endif /* _UTIL_H_ */ #endif /* _UTIL_H_ */