Skip to content
Snippets Groups Projects
Commit 35462e71 authored by Henrik (Grubba) Grubbström's avatar Henrik (Grubba) Grubbström
Browse files

HTTPLoop: Get the log_lock before messing with log_head.

Fixes unlikely race in cleanup code on accept(2) failing with EBADF.

Fixes [CID 742665].
parent bd67f64d
No related branches found
No related tags found
No related merge requests found
...@@ -461,6 +461,20 @@ static void low_accept_loop(struct args *arg) ...@@ -461,6 +461,20 @@ static void low_accept_loop(struct args *arg)
struct cache *c, *p = NULL; struct cache *c, *p = NULL;
struct log *l, *n = NULL; struct log *l, *n = NULL;
/* oups. */ /* oups. */
/* NB: log_head is protected by the log_lock mutex. */
mt_lock(&arg->log->log_lock);
while(arg->log->log_head)
{
struct log_entry *l = arg->log->log_head->next;
free(arg->log->log_head);
arg->log->log_head = l;
}
mt_unlock(&arg->log->log_lock);
/* NB: The cache, and the variables first_cache and aap_first_log
* are protected by the interpreter lock.
*/
low_mt_lock_interpreter(); /* Can run even if threads_disabled. */ low_mt_lock_interpreter(); /* Can run even if threads_disabled. */
for(i=0; i<CACHE_HTABLE_SIZE; i++) for(i=0; i<CACHE_HTABLE_SIZE; i++)
{ {
...@@ -475,12 +489,6 @@ static void low_accept_loop(struct args *arg) ...@@ -475,12 +489,6 @@ static void low_accept_loop(struct args *arg)
free(t); free(t);
} }
} }
while(arg->log->log_head)
{
struct log_entry *l = arg->log->log_head->next;
free(arg->log->log_head);
arg->log->log_head = l;
}
c = first_cache; c = first_cache;
while(c && c != arg->cache) {p=c;c = c->next;} while(c && c != arg->cache) {p=c;c = c->next;}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment