git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] threaded pack-objects: Use condition variables for thread communication.

From
Johannes Sixt <j.sixt@viscovery.net>
Date
Dec 17, 2007, 07:44 UTC
Message-ID
<476628D1.4020300@viscovery.net>
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...
Show 6 quoted lines
>  	}
>  
> +	/* Start work threads. */
> +	for (i = 0; i < delta_search_threads; i++) {
> +		if (!p[i].list_size)
> +			continue;
... should go here because...
Show 6 quoted lines
> +		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
Previous: Nicolas PitreNext: Johannes Sixt
Message 8 of 11 in “threaded pack-objects: Use condition variables for thread communication.”
  1. threaded pack-objects: Use condition variables for thread communication.Johannes Sixt, Dec 15, 2007
  2. Peter BaumannDec 16, 2007
  3. Johannes SixtDec 16, 2007
  4. Peter BaumannDec 16, 2007
  5. threaded pack-objects: Use condition variables for thread communication.Johannes Sixt, Dec 16, 2007
  6. Junio C HamanoDec 16, 2007
  7. Nicolas PitreDec 17, 2007
  8. Johannes SixtDec 17, 2007
  9. Plug a resource leak in threaded pack-objects code.Johannes Sixt, Dec 17, 2007
  10. Dmitry PotapovDec 17, 2007
  11. David BrownDec 16, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.