changeset 3132:f8686c591e49

neon: More gracefully handle the NEON_READER_ERROR condition.
author William Pitcock <nenolod@atheme.org>
date Thu, 07 May 2009 00:30:11 -0500
parents 3c445626fcc8
children 005959102811
files src/neon/neon.c
diffstat 1 files changed, 15 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/neon/neon.c	Thu May 07 06:24:49 2009 +0200
+++ b/src/neon/neon.c	Thu May 07 00:30:11 2009 -0500
@@ -1043,6 +1043,17 @@
                  * All is well, nothing to be done.
                  */
                 break;
+            case NEON_READER_ERROR:
+                /*
+                 * A reader error happened. Log it, and treat it like an EOF condition, by falling through
+                 * to the NEON_READER_EOF codepath.  --nenolod
+                 */
+                _DEBUG("<%p> NEON_READER_ERROR happened. Terminating reader thread and marking EOF.", h);
+                h->reader_status.status = NEON_READER_EOF;
+
+                if (NULL != h->reader)
+                    kill_reader(h);
+
             case NEON_READER_EOF:
                 /*
                  * If there still is data in the buffer, carry on.
@@ -1051,17 +1062,14 @@
                 if (0 == used_rb_locked(&h->rb)) {
                     _DEBUG("<%p> Reached end of stream", h);
                     g_mutex_unlock(h->reader_status.mutex);
-                    kill_reader(h);
+
+                    if (NULL != h->reader)
+                        kill_reader(h);
+
                     h->eof = TRUE;
                     _LEAVE 0;
                 }
                 break;
-            case NEON_READER_ERROR:
-                /* Terminate the reader and return 0 */
-                g_mutex_unlock(h->reader_status.mutex);
-                kill_reader(h);
-                _LEAVE 0;
-                break;
             case NEON_READER_TERM:
                 /*
                  * The reader thread terminated gracefully, most