[PATCH 31/31] source: make get_next_buffer try only 10 times and then bail out

Niv Sardi <[email protected]>
Newsgroups gmane.comp.audio.icecast.devel
Message-ID <[email protected]>
Signed-off-by: Niv Sardi <[email protected]>
---
 src/source.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/src/source.c b/src/source.c
index fa99180..796c548 100644
--- a/src/source.c
+++ b/src/source.c
@@ -457,6 +457,7 @@ static refbuf_t *get_next_buffer (source_t *source)
 {
     refbuf_t *refbuf = NULL;
     int delay = 250;
+    int try = 0;
 
     if (source->short_delay)
         delay = 0;
@@ -465,6 +466,11 @@ static refbuf_t *get_next_buffer (source_t *source)
         int fds = 0;
         time_t current = time (NULL);
 
+        if (try++ > 10) {
+            WARN ("Error while waiting on socket (too many trys (%d)), Disconnecting source", try);
+            source->running = 0;
+        }
+
         if (source->client)
             fds = util_timed_wait_for_fd (source->con->sock, delay);
         else
-- 
1.7.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.