kqueue: Clear sleep counter before wakeup
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Mon, 7 Mar 2016 12:43:17 +0000 (20:43 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Mon, 7 Mar 2016 12:43:17 +0000 (20:43 +0800)
sys/kern/kern_event.c

index 1099ff6..f1eb9f4 100644 (file)
@@ -1430,11 +1430,13 @@ static void
 kqueue_wakeup(struct kqueue *kq)
 {
        if (kq->kq_sleep_cnt) {
-               if (kq->kq_sleep_cnt == 1)
+               u_int sleep_cnt = kq->kq_sleep_cnt;
+
+               kq->kq_sleep_cnt = 0;
+               if (sleep_cnt == 1)
                        wakeup_one(kq);
                else
                        wakeup(kq);
-               kq->kq_sleep_cnt = 0;
        }
        KNOTE(&kq->kq_kqinfo.ki_note, 0);
 }