lib/plist.c: fix xbps_array_foreach_cb_multi processing entries multiple times
the first thread to finish will start again from 0 (`reserved`) until 0+slicecount, next thread will then start from the end of the previous thread which is already wrong, resulting in processing the first slicecount*maxthreads entries twice. The first slicecount*maxthreads entries are accounted by the thread creation loop and `reserved` has to start at the first unaccounted index.
This commit is contained in:
@ -103,7 +103,7 @@ xbps_array_foreach_cb_multi(struct xbps_handle *xhp,
|
|||||||
struct thread_data *thd;
|
struct thread_data *thd;
|
||||||
unsigned int arraycount, slicecount;
|
unsigned int arraycount, slicecount;
|
||||||
int rv = 0, maxthreads;
|
int rv = 0, maxthreads;
|
||||||
unsigned int reserved = 0;
|
unsigned int reserved;
|
||||||
pthread_spinlock_t reserved_lock;
|
pthread_spinlock_t reserved_lock;
|
||||||
|
|
||||||
assert(fn != NULL);
|
assert(fn != NULL);
|
||||||
@ -138,6 +138,8 @@ xbps_array_foreach_cb_multi(struct xbps_handle *xhp,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reserved = slicecount * maxthreads;
|
||||||
|
|
||||||
for (int i = 0; i < maxthreads; i++) {
|
for (int i = 0; i < maxthreads; i++) {
|
||||||
thd[i].array = array;
|
thd[i].array = array;
|
||||||
thd[i].dict = dict;
|
thd[i].dict = dict;
|
||||||
|
Reference in New Issue
Block a user