fix rend_init before detach bug in main. Oops

This commit is contained in:
Ron Pedde 2004-12-08 03:20:48 +00:00
parent e7b4e3879b
commit f36c8d20d0
1 changed files with 15 additions and 15 deletions

View File

@ -165,9 +165,9 @@ void daap_handler(WS_CONNINFO *pwsc) {
/* for the /databases URI */ /* for the /databases URI */
char *uri; char *uri;
int db_index; unsigned long int db_index;
int playlist_index; unsigned long int playlist_index;
int item=0; unsigned long int item=0;
char *first, *last; char *first, *last;
char* index = 0; char* index = 0;
int streaming=0; int streaming=0;
@ -252,7 +252,7 @@ void daap_handler(WS_CONNINFO *pwsc) {
if(*last) { if(*last) {
*last='\0'; *last='\0';
db_index=atoi(first); db_index=atoll(first);
last++; last++;
@ -264,9 +264,9 @@ void daap_handler(WS_CONNINFO *pwsc) {
if(*last == '.') { if(*last == '.') {
*last='\0'; *last='\0';
item=atoi(first); item=atoll(first);
streaming=1; streaming=1;
DPRINTF(E_DBG,L_DAAP|L_WS,"Streaming request for id %d\n",item); DPRINTF(E_DBG,L_DAAP|L_WS,"Streaming request for id %lu\n",item);
} }
free(uri); free(uri);
} else if (strncasecmp(last,"items",5)==0) { } else if (strncasecmp(last,"items",5)==0) {
@ -287,7 +287,7 @@ void daap_handler(WS_CONNINFO *pwsc) {
if(*last) { if(*last) {
*last='\0'; *last='\0';
playlist_index=atoi(first); playlist_index=atoll(first);
// pass the meta list info for processing // pass the meta list info for processing
root=daap_response_playlist_items(playlist_index, root=daap_response_playlist_items(playlist_index,
ws_getvar(pwsc,"meta"), ws_getvar(pwsc,"meta"),
@ -352,7 +352,7 @@ void daap_handler(WS_CONNINFO *pwsc) {
pmp3=db_find(item); pmp3=db_find(item);
if(!pmp3) { if(!pmp3) {
DPRINTF(E_LOG,L_DAAP|L_WS|L_DB,"Could not find requested item %d\n",item); DPRINTF(E_LOG,L_DAAP|L_WS|L_DB,"Could not find requested item %lu\n",item);
ws_returnerror(pwsc,404,"File Not Found"); ws_returnerror(pwsc,404,"File Not Found");
} else { } else {
/* got the file, let's open and serve it */ /* got the file, let's open and serve it */
@ -773,8 +773,6 @@ int main(int argc, char *argv[]) {
write_pid_file(); write_pid_file();
} }
/* block signals and set up the signal handling thread */ /* block signals and set up the signal handling thread */
DPRINTF(E_LOG,L_MAIN,"Starting signal handler\n"); DPRINTF(E_LOG,L_MAIN,"Starting signal handler\n");
if(start_signal_handler(&signal_tid)) { if(start_signal_handler(&signal_tid)) {
@ -802,6 +800,13 @@ int main(int argc, char *argv[]) {
} }
/* Wait as long as we can to detach */
if(!foreground) {
daemon_start();
}
/* Have to do rend_init after daemon_start, to avoid closing
* the pipe */
#ifndef WITHOUT_MDNS #ifndef WITHOUT_MDNS
if((config.use_mdns) && (!parseonly)) { if((config.use_mdns) && (!parseonly)) {
DPRINTF(E_LOG,L_MAIN,"Starting rendezvous daemon\n"); DPRINTF(E_LOG,L_MAIN,"Starting rendezvous daemon\n");
@ -811,11 +816,6 @@ int main(int argc, char *argv[]) {
} }
#endif #endif
/* Wait as long as we can to detach */
if(!foreground) {
daemon_start();
}
// Drop privs here // Drop privs here
if(drop_privs(config.runas)) { if(drop_privs(config.runas)) {
DPRINTF(E_FATAL,L_MAIN,"Error in drop_privs: %s\n",strerror(errno)); DPRINTF(E_FATAL,L_MAIN,"Error in drop_privs: %s\n",strerror(errno));