kernel - Remove SMP bottlenecks on uidinfo, descriptors, and lockf (2)
authorMatthew Dillon <dillon@apollo.backplane.com>
Sun, 22 Apr 2018 17:34:22 +0000 (10:34 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Sun, 22 Apr 2018 17:35:07 +0000 (10:35 -0700)
* Fix lost fp bug, a file pointer would sometimes not get dropped,
  leading to disconnection problems (e.g. sftp).

sys/kern/kern_event.c

index 1f02786..3203c49 100644 (file)
@@ -1393,8 +1393,11 @@ again:
                goto done;
        }
        ++kev;
-       if (count < climit)
+       if (count < climit) {
+               if (fp[count-1])                /* drop unprocessed fp */
+                       fdrop(fp[count-1]);
                goto loop;
+       }
 
        /*
         * Cleanup
@@ -1409,7 +1412,12 @@ done:
        }
        lwkt_relpooltoken(kq);
 
+       /*
+        * Drop unprocessed file pointers
+        */
        *countp = count;
+       if (count && fp[count-1])
+               fdrop(fp[count-1]);
        while (count < climit) {
                if (fp[count])
                        fdrop(fp[count]);