Created
June 16, 2012 09:10
-
-
Save trustin/2940640 to your computer and use it in GitHub Desktop.
hairtunes.c patch that fixes stall hairtunes process
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/hairtunes.c b/hairtunes.c | |
index 6859cff..b5f3e7e 100644 | |
--- a/hairtunes.c | |
+++ b/hairtunes.c | |
@@ -417,17 +417,25 @@ static void *rtp_thread_func(void *arg) { | |
int sock = rtp_sockets[0], csock = rtp_sockets[1]; | |
int readsock; | |
char type; | |
+ struct timeval timeout; | |
fd_set fds; | |
FD_ZERO(&fds); | |
FD_SET(sock, &fds); | |
FD_SET(csock, &fds); | |
- while (select(csock>sock ? csock+1 : sock+1, &fds, 0, 0, 0)!=-1) { | |
+ for (;;) { | |
+ timeout.tv_sec = 5; | |
+ timeout.tv_usec = 0; | |
+ if (select(csock>sock ? csock+1 : sock+1, &fds, 0, 0, &timeout) == -1) { | |
+ break; | |
+ } | |
if (FD_ISSET(sock, &fds)) { | |
readsock = sock; | |
- } else { | |
+ } else if (FD_ISSET(csock, &fds)) { | |
readsock = csock; | |
+ } else { | |
+ break; | |
} | |
FD_SET(sock, &fds); | |
FD_SET(csock, &fds); | |
@@ -449,6 +457,8 @@ static void *rtp_thread_func(void *arg) { | |
} | |
} | |
+ die("rtp_thread_func() terminated."); | |
+ | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment