Fix deadlock when fetching stylesheets when max_fetchers_per_host is reached by splitting fetch_can_be_freed() into fetch_remove_from_queues() and fetch_free().

svn path=/trunk/netsurf/; revision=3380
This commit is contained in:
James Bursa 2007-07-04 18:44:13 +00:00
parent 960c11de1a
commit 594eb74c4c
3 changed files with 11 additions and 9 deletions

View File

@ -89,7 +89,6 @@ static void fetch_unref_fetcher(scheme_fetcher *fetcher);
static void fetch_dispatch_jobs(void); static void fetch_dispatch_jobs(void);
static bool fetch_choose_and_dispatch(void); static bool fetch_choose_and_dispatch(void);
static bool fetch_dispatch_job(struct fetch *fetch); static bool fetch_dispatch_job(struct fetch *fetch);
static void fetch_free(struct fetch *f);
/** /**
@ -544,8 +543,8 @@ fetch_send_callback(fetch_msg msg, struct fetch *fetch, const void *data,
fetch->callback(msg, fetch->p, data, size); fetch->callback(msg, fetch->p, data, size);
} }
void
fetch_can_be_freed(struct fetch *fetch) void fetch_remove_from_queues(struct fetch *fetch)
{ {
int all_active, all_queued; int all_active, all_queued;
@ -565,10 +564,9 @@ fetch_can_be_freed(struct fetch *fetch)
LOG(("Fetch ring is now %d elements.", all_active)); LOG(("Fetch ring is now %d elements.", all_active));
LOG(("Queue ring is now %d elements.", all_queued)); LOG(("Queue ring is now %d elements.", all_queued));
fetch_free(fetch);
} }
void void
fetch_set_http_code(struct fetch *fetch, long http_code) fetch_set_http_code(struct fetch *fetch, long http_code)
{ {

View File

@ -110,7 +110,8 @@ bool fetch_add_fetcher(const char *scheme,
void fetch_send_callback(fetch_msg msg, struct fetch *fetch, void fetch_send_callback(fetch_msg msg, struct fetch *fetch,
const void *data, unsigned long size); const void *data, unsigned long size);
void fetch_can_be_freed(struct fetch *fetch); void fetch_remove_from_queues(struct fetch *fetch);
void fetch_free(struct fetch *f);
void fetch_set_http_code(struct fetch *fetch, long http_code); void fetch_set_http_code(struct fetch *fetch, long http_code);
const char *fetch_get_referer_to_send(struct fetch *fetch); const char *fetch_get_referer_to_send(struct fetch *fetch);
#endif #endif

View File

@ -644,7 +644,8 @@ void fetch_curl_abort(void *vf)
if (f->curl_handle) { if (f->curl_handle) {
f->abort = true; f->abort = true;
} else { } else {
fetch_can_be_freed(f->fetch_handle); fetch_remove_from_queues(f->fetch_handle);
fetch_free(f->fetch_handle);
} }
} }
@ -672,7 +673,7 @@ void fetch_curl_stop(struct curl_fetch_info *f)
f->curl_handle = 0; f->curl_handle = 0;
} }
fetch_can_be_freed(f->fetch_handle); fetch_remove_from_queues(f->fetch_handle);
} }
@ -808,6 +809,8 @@ void fetch_curl_done(CURL *curl_handle, CURLcode result)
else else
error = true; error = true;
fetch_curl_stop(f);
/* If finished, acquire cache info to pass to callback */ /* If finished, acquire cache info to pass to callback */
if (finished) { if (finished) {
memcpy(&cachedata, &f->cachedata, sizeof(struct cache_data)); memcpy(&cachedata, &f->cachedata, sizeof(struct cache_data));
@ -908,7 +911,7 @@ void fetch_curl_done(CURL *curl_handle, CURLcode result)
fetch_send_callback(FETCH_ERROR, f->fetch_handle, fetch_send_callback(FETCH_ERROR, f->fetch_handle,
fetch_error_buffer, 0); fetch_error_buffer, 0);
fetch_curl_stop(f); fetch_free(f->fetch_handle);
} }