nginx-0.0.1-2003-10-12-20:49:16 import
diff --git a/src/os/unix/ngx_recv.c b/src/os/unix/ngx_recv.c
index 1545654..cef4328 100644
--- a/src/os/unix/ngx_recv.c
+++ b/src/os/unix/ngx_recv.c
@@ -43,8 +43,11 @@
         if (n >= 0) {
             if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) {
                 rev->available -= n;
-                if (rev->available == 0) {
+                if (rev->available <= 0) {
                     rev->ready = 0;
+                    if (rev->available < 0) {
+                        rev->available = 0;
+                    }
                 }
 
                 return n;