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:
parent
173c834fc8
commit
a4dd0221ac
@ -103,7 +103,7 @@ xbps_array_foreach_cb_multi(struct xbps_handle *xhp,
|
||||
struct thread_data *thd;
|
||||
unsigned int arraycount, slicecount;
|
||||
int rv = 0, maxthreads;
|
||||
unsigned int reserved = 0;
|
||||
unsigned int reserved;
|
||||
pthread_spinlock_t reserved_lock;
|
||||
|
||||
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++) {
|
||||
thd[i].array = array;
|
||||
thd[i].dict = dict;
|
||||
|
Loading…
Reference in New Issue
Block a user