httpd_output: check client->write_source_id in handler

Due to a race condition, httpd_client_out_event() could be called even
when its GLib event source was already removed.  Check that case.
This commit is contained in:
Max Kellermann 2009-03-15 19:06:14 +01:00
parent 58844aabac
commit 870706519a
1 changed files with 7 additions and 0 deletions

View File

@ -459,6 +459,13 @@ httpd_client_out_event(GIOChannel *source,
assert(condition == G_IO_OUT);
assert(client->state == RESPONSE);
if (client->write_source_id == 0) {
/* another thread has removed the event source while
this thread was waiting for httpd->mutex */
g_mutex_unlock(httpd->mutex);
return false;
}
if (client->current_page == NULL) {
client->current_page = g_queue_pop_head(client->pages);
client->current_position = 0;