From aa7b69808626e2d8ff17678fd1d0dc6d1e03ba5a Mon Sep 17 00:00:00 2001 From: Warren Dukes Date: Sat, 12 Mar 2005 22:38:49 +0000 Subject: *) slight code cleanup *) now --kill will not check for /proc//exe (this is linux specific) git-svn-id: https://svn.musicpd.org/mpd/trunk@3063 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- src/interface.c | 25 +++++++++++++++---------- src/main.c | 10 +++++----- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/interface.c b/src/interface.c index fd33382e8..fac7af771 100644 --- a/src/interface.c +++ b/src/interface.c @@ -393,21 +393,28 @@ int doIOForInterfaces() { struct timeval tv; int i; int selret; - int fdmax = 0; + int fdmax; tv.tv_sec = 1; tv.tv_usec = 0; - addInterfacesReadyToReadAndListenSocketToFdSet(&rfds,&fdmax); - addInterfacesForBufferFlushToFdSet(&wfds,&fdmax); + while(1) { + fdmax = 0; - while((selret = select(fdmax+1,&rfds,&wfds,NULL,&tv))) { - getConnections(&rfds); - if(selret<0 && errno==EINTR) break; - else if(selret<0) { + addInterfacesReadyToReadAndListenSocketToFdSet(&rfds,&fdmax); + addInterfacesForBufferFlushToFdSet(&wfds,&fdmax); + + selret = select(fdmax+1,&rfds,&wfds,NULL,&tv); + + if(selret == 0 || (selret<0 && errno==EINTR)) break; + + if(selret<0) { closeNextErroredInterface(); continue; } + + getConnections(&rfds); + for(i=0;ivalue,"r"); if(!fp) { @@ -405,7 +405,7 @@ void killFromPidFile(char * cmd, int killOption) { } fclose(fp); - memset(buf, 0, 32); + /*memset(buf, 0, 32); snprintf(buf, 31, "/proc/%i/exe", pid); if(killOption == 1) { @@ -430,7 +430,7 @@ void killFromPidFile(char * cmd, int killOption) { cmd, pid); exit(EXIT_FAILURE); } - } + }*/ if(kill(pid, SIGTERM)) { ERROR("unable to kill proccess %i: %s\n", pid, strerror(errno)); @@ -492,9 +492,9 @@ int main(int argc, char * argv[]) { readPlaylistState(); while(COMMAND_RETURN_KILL!=doIOForInterfaces()) { + if(COMMAND_RETURN_KILL==handlePendingSignals()) break; syncPlayerAndPlaylist(); closeOldInterfaces(); - if(COMMAND_RETURN_KILL==handlePendingSignals()) break; readDirectoryDBIfUpdateIsFinished(); } -- cgit v1.2.3