summaryrefslogtreecommitdiffstats
path: root/src/mpq.h
diff options
context:
space:
mode:
authorMatt Dunwoodie <ncon@mail.noconroy.net>2019-09-10 00:20:45 +1000
committerMatt Dunwoodie <ncon@mail.noconroy.net>2019-09-10 00:20:45 +1000
commit3eb0ccbbefab9ee7e1d77ccb6826ea0bcd031db7 (patch)
treefc1d5f8a9b72bf605cd7cc7f0b144a362d36b878 /src/mpq.h
parentAdd WIREGUARD config option (diff)
downloadwireguard-openbsd-3eb0ccbbefab9ee7e1d77ccb6826ea0bcd031db7.tar.xz
wireguard-openbsd-3eb0ccbbefab9ee7e1d77ccb6826ea0bcd031db7.zip
Minor mpq.h bugfixes
Diffstat (limited to 'src/mpq.h')
-rw-r--r--src/mpq.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/mpq.h b/src/mpq.h
index de9a386230d..d7c8a19a0c0 100644
--- a/src/mpq.h
+++ b/src/mpq.h
@@ -69,6 +69,7 @@ _mpq_thread(struct mpq *mpq)
tid = mpq->mpq_nthreads++;
while (1) {
if (tid >= mpq->mpq_wantthreads) {
+ mpq->mpq_nthreads--;
mtx_leave(&mpq->mpq_mtx);
kthread_exit(0);
}
@@ -152,10 +153,8 @@ mpq_size(struct mpq *mpq, size_t size)
bzero(mpi, size * sizeof(struct mpi));
- if (mpq->mpq_items != NULL) {
+ if (mpq->mpq_items != NULL)
memcpy(mpi, mpq->mpq_items, mpq->mpq_itemssize * sizeof(struct mpi));
- free(mpq->mpq_items, M_DEVBUF, 0);
- }
mpq->mpq_itemssize = size;
tmp = mpq->mpq_items;
@@ -181,6 +180,7 @@ mpq_nthreads(struct mpq *mpq, size_t nthreads)
old_nthreads = mpq->mpq_wantthreads;
mpq->mpq_wantthreads = nthreads;
mtx_leave(&mpq->mpq_mtx);
+ wakeup(&mpq->mpq_phead);
while (old_nthreads++ < nthreads)
kthread_create((void (*)(void *))_mpq_thread, mpq, NULL, "wg");
}