mirror of
https://github.com/mirror/wget.git
synced 2025-03-14 20:00:15 +08:00
Correct a source of memory leak when --jobs is not explicitly specified.
This commit is contained in:
parent
721697aef6
commit
f51826d9d8
@ -29,14 +29,14 @@ spawn_thread (struct s_thread_ctx *thread_ctx, int index, int resource)
|
||||
}
|
||||
|
||||
int
|
||||
collect_thread (sem_t *retr_sem, struct s_thread_ctx *thread_ctx)
|
||||
collect_thread (sem_t *retr_sem, struct s_thread_ctx *thread_ctx, int numthreads)
|
||||
{
|
||||
int k, ret;
|
||||
do
|
||||
ret = sem_wait (retr_sem);
|
||||
while (ret < 0 && errno == EINTR);
|
||||
|
||||
for (k = 0; k < opt.jobs; k++)
|
||||
for (k = 0; k < numthreads; k++)
|
||||
if (thread_ctx[k].used && thread_ctx[k].terminated)
|
||||
{
|
||||
url_free (thread_ctx[k].url_parsed);
|
||||
|
@ -58,7 +58,7 @@ struct s_thread_ctx
|
||||
|
||||
int spawn_thread (struct s_thread_ctx*, int, int);
|
||||
|
||||
int collect_thread (sem_t *, struct s_thread_ctx *);
|
||||
int collect_thread (sem_t *, struct s_thread_ctx *, int);
|
||||
|
||||
static void * segmented_retrieve_url (void *);
|
||||
|
||||
|
@ -1168,7 +1168,7 @@ retrieve_from_file (const char *file, bool html, int *count)
|
||||
|
||||
while(ranges_covered < N_THREADS)
|
||||
{
|
||||
r = collect_thread (&retr_sem, thread_ctx);
|
||||
r = collect_thread (&retr_sem, thread_ctx, N_THREADS);
|
||||
++ranges_covered;
|
||||
|
||||
status = thread_ctx[r].status;
|
||||
|
Loading…
Reference in New Issue
Block a user