xbps_array_foreach_cb_multi: fix incorrect array counter.
This fixes some races that could be seen when there's a determined number of pkgs and CPU threads.
This commit is contained in:
parent
580a5ba29b
commit
08aa44602f
@ -111,10 +111,12 @@ xbps_array_foreach_cb_multi(struct xbps_handle *xhp,
|
|||||||
if (xbps_object_type(array) != XBPS_TYPE_ARRAY)
|
if (xbps_object_type(array) != XBPS_TYPE_ARRAY)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
arraycount = xbps_array_count(array);
|
if (!xbps_array_count(array))
|
||||||
if (arraycount == 0)
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
/* - 1 because there's a private dict used internally */
|
||||||
|
arraycount = xbps_array_count(array) - 1;
|
||||||
|
|
||||||
maxthreads = (int)sysconf(_SC_NPROCESSORS_ONLN);
|
maxthreads = (int)sysconf(_SC_NPROCESSORS_ONLN);
|
||||||
if (maxthreads <= 1 || arraycount <= 1) /* use single threaded routine */
|
if (maxthreads <= 1 || arraycount <= 1) /* use single threaded routine */
|
||||||
return xbps_array_foreach_cb(xhp, array, dict, fn, arg);
|
return xbps_array_foreach_cb(xhp, array, dict, fn, arg);
|
||||||
|
Loading…
Reference in New Issue
Block a user