git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Derrick Stolee <stolee@gmail.com>
To: "René Scharfe" <l.s.r@web.de>, "Git Mailing List" <git@vger.kernel.org>
Cc: "Junio C Hamano" <gitster@pobox.com>,
	"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: Re: [PATCH] sha1-name: make sort_ambiguous_oid_array() thread-safe
Date: Tue, 20 Aug 2019 14:57:04 -0400	[thread overview]
Message-ID: <7000e687-800b-c613-aa90-e022bd30a023@gmail.com> (raw)
In-Reply-To: <a08751c7-170d-7faf-272e-79c589ec3eab@web.de>

On 8/20/2019 2:49 PM, René Scharfe wrote:
> Use QSORT_S instead of QSORT, which allows passing the repository
> pointer to the comparison function without using a static variable.

Makes sense.

> -static struct repository *sort_ambiguous_repo;
> -static int sort_ambiguous(const void *a, const void *b)
> +static int sort_ambiguous(const void *a, const void *b, void *ctx)
>  {
> +	struct repository *sort_ambiguous_repo = ctx;
>  	int a_type = oid_object_info(sort_ambiguous_repo, a, NULL);
>  	int b_type = oid_object_info(sort_ambiguous_repo, b, NULL);
>  	int a_type_sort;
> @@ -434,10 +434,7 @@ static int sort_ambiguous(const void *a, const void *b)
> 
>  static void sort_ambiguous_oid_array(struct repository *r, struct oid_array *a)
>  {
> -	/* mutex will be needed if this code is to be made thread safe */
> -	sort_ambiguous_repo = r;
> -	QSORT(a->oid, a->nr, sort_ambiguous);
> -	sort_ambiguous_repo = NULL;
> +	QSORT_S(a->oid, a->nr, sort_ambiguous, r);
>  }

LGTM!

Thanks,
-Stolee

      reply	other threads:[~2019-08-20 18:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-20 18:49 [PATCH] sha1-name: make sort_ambiguous_oid_array() thread-safe René Scharfe
2019-08-20 18:57 ` Derrick Stolee [this message]

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=7000e687-800b-c613-aa90-e022bd30a023@gmail.com \
    --to=stolee@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=l.s.r@web.de \
    --cc=pclouds@gmail.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).