Skip to content

Instantly share code, notes, and snippets.

@trustin
Created June 16, 2012 09:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trustin/2940640 to your computer and use it in GitHub Desktop.
Save trustin/2940640 to your computer and use it in GitHub Desktop.
hairtunes.c patch that fixes stall hairtunes process
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