# HG changeset patch # User Ralf Ertzinger # Date 1195743162 -3600 # Node ID f2590691d4b732271026f81699b6b75035ea689b # Parent b73ea297d197dd270d82b8c0cdaf454dcd8e4648 - Fix locking issues causing spurious error messages (and possibly deadlocks) diff -r b73ea297d197 -r f2590691d4b7 src/neon/neon.c --- a/src/neon/neon.c Thu Nov 22 15:51:52 2007 +0100 +++ b/src/neon/neon.c Thu Nov 22 15:52:42 2007 +0100 @@ -885,7 +885,8 @@ * We have to check if the reader terminated gracefully * again */ - if (NEON_READER_TERM != h->reader_status.status) { + if ((NEON_READER_TERM != h->reader_status.status) && + (NEON_READER_EOF != h->reader_status.status)) { /* * Reader thread did not terminate gracefully. */ @@ -918,13 +919,14 @@ * We have some data in the buffer now. * Start the reader thread. */ + g_mutex_lock(h->reader_status.mutex); h->reader_status.reading = TRUE; if (NULL == (h->reader = g_thread_create(reader_thread, h, TRUE, NULL))) { h->reader_status.reading = FALSE; + g_mutex_unlock(h->reader_status.mutex); _ERROR("Error creating reader thread!"); _LEAVE 0; } - g_mutex_lock(h->reader_status.mutex); h->reader_status.status = NEON_READER_RUN; g_mutex_unlock(h->reader_status.mutex); } else { @@ -946,7 +948,7 @@ * If there still is data in the buffer, carry on. * If not, terminate the reader thread and return 0. */ - if (0 == used_rb(&h->rb)) { + if (0 == used_rb_locked(&h->rb)) { _DEBUG("Reached end of stream"); g_mutex_unlock(h->reader_status.mutex); kill_reader(h);