git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Sixt <j.sixt@viscovery.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Peter Baumann <waste.manager@gmx.de>,
	git@vger.kernel.org, Nicolas Pitre <nico@cam.org>
Subject: Re: [PATCH v2] threaded pack-objects: Use condition variables for thread communication.
Date: Mon, 17 Dec 2007 08:44:17 +0100	[thread overview]
Message-ID: <476628D1.4020300@viscovery.net> (raw)
In-Reply-To: <200712162045.34456.johannes.sixt@telecom.at>

I just discovered a theoretical resource leakage:

> +	/* Partition the work amongst work threads. */
>  	for (i = 0; i < delta_search_threads; i++) {
...
> +		pthread_mutex_init(&p[i].mutex, NULL);
> +		pthread_cond_init(&p[i].cond, NULL);

These two initializations...

>  	}
>  
> +	/* Start work threads. */
> +	for (i = 0; i < delta_search_threads; i++) {
> +		if (!p[i].list_size)
> +			continue;

... should go here because...

> +		ret = pthread_create(&p[i].thread, NULL,
> +				     threaded_find_deltas, &p[i]);
> +		if (ret)
> +			die("unable to create thread: %s", strerror(ret));
> +		active_threads++;
> +	}
...
> +	while (active_threads) {
...
>  		if (!sub_size) {
>  			pthread_join(target->thread, NULL);
> +			pthread_cond_destroy(&target->cond);
> +			pthread_mutex_destroy(&target->mutex);

... we tear down only those for which we actually started a thread.

>  			active_threads--;
>  		}
> +	}

Will send a patch this evening.

-- Hannes

  parent reply	other threads:[~2007-12-17  7:44 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-15 23:18 [PATCH] threaded pack-objects: Use condition variables for thread communication Johannes Sixt
2007-12-16 12:05 ` Peter Baumann
2007-12-16 18:41   ` Johannes Sixt
2007-12-16 19:00     ` Peter Baumann
2007-12-16 19:45       ` [PATCH v2] " Johannes Sixt
2007-12-16 22:12         ` Junio C Hamano
2007-12-17  3:13         ` Nicolas Pitre
2007-12-17  7:44         ` Johannes Sixt [this message]
2007-12-17 19:12           ` [PATCH] Plug a resource leak in threaded pack-objects code Johannes Sixt
2007-12-17  4:26       ` [PATCH] threaded pack-objects: Use condition variables for thread communication Dmitry Potapov
2007-12-16 19:18     ` David Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=476628D1.4020300@viscovery.net \
    --to=j.sixt@viscovery.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=nico@cam.org \
    --cc=waste.manager@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).