Index: sys/kern/uipc_socket.c
diff -u sys/kern/uipc_socket.c:1.68.2.20 sys/kern/uipc_socket.c:1.68.2.21
--- sys/kern/uipc_socket.c:1.68.2.20	Sun Apr 28 16:38:13 2002
+++ sys/kern/uipc_socket.c	Tue Apr 30 22:27:35 2002
@@ -256,7 +256,6 @@
 		} else {
 			panic("sofree: not queued");
 		}
-		head->so_qlen--;
 		so->so_state &= ~SS_INCOMP;
 		so->so_head = NULL;
 	}
@@ -1641,6 +1640,6 @@
 {
 	struct socket *so = (struct socket *)kn->kn_fp->f_data;
 
-	kn->kn_data = so->so_qlen - so->so_incqlen;
+	kn->kn_data = so->so_qlen;
 	return (! TAILQ_EMPTY(&so->so_comp));
 }
Index: sys/kern/uipc_socket2.c
diff -u sys/kern/uipc_socket2.c:1.55.2.13 sys/kern/uipc_socket2.c:1.55.2.15
--- sys/kern/uipc_socket2.c:1.55.2.15	Tue Apr 30 22:26:30 2002
+++ sys/kern/uipc_socket2.c	Tue Apr 30 22:27:35 2002
@@ -123,6 +123,7 @@
 		head->so_incqlen--;
 		so->so_state &= ~SS_INCOMP;
 		TAILQ_INSERT_TAIL(&head->so_comp, so, so_list);
+		head->so_qlen++;
 		so->so_state |= SS_COMP;
 		sorwakeup(head);
 		wakeup_one(&head->so_timeo);
@@ -207,12 +208,17 @@
 	if (connstatus) {
 		TAILQ_INSERT_TAIL(&head->so_comp, so, so_list);
 		so->so_state |= SS_COMP;
+		head->so_qlen++;
 	} else {
+		if (head->so_incqlen > head->so_qlimit) {
+			struct socket *sp;
+			sp = TAILQ_FIRST(&head->so_incomp);
+			(void) soabort(sp);
+		}
 		TAILQ_INSERT_TAIL(&head->so_incomp, so, so_list);
 		so->so_state |= SS_INCOMP;
 		head->so_incqlen++;
 	}
-	head->so_qlen++;
 	if (connstatus) {
 		sorwakeup(head);
 		wakeup((caddr_t)&head->so_timeo);
