Re: [PATCH] sha1-name: make sort_ambiguous_oid_array() thread-safe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux