about summary refs log tree commit homepage
diff options
context:
space:
mode:
-rw-r--r--ioq.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/ioq.c b/ioq.c
index 0a32c71..772da38 100644
--- a/ioq.c
+++ b/ioq.c
@@ -46,8 +46,14 @@ bool mog_ioq_ready(struct mog_ioq *ioq, struct mog_fd *client_mfd)
         CHECK(int, 0, pthread_mutex_lock(&ioq->mtx));
 
         good = ioq->cur > 0;
-        if (good) { /* uncontended case is simple */
-                ioq->cur--;
+        if (good) {
+                /*
+                 * assume the worst when we are the last one to
+                 * acquire a free slot
+                 */
+                if (--ioq->cur == 0)
+                        ioq_set_contended(ioq);
+
                 mog_ioq_current = ioq;
         } else {
                 client_mfd->ioq_blocked = 1;