Hello, kernel-ites:
I mentioned this in an earlier message titled "kernel blocks too
long with SO_LINGER", and since that time I did some investigation, and
have come to the conclusion that there is an error in the 2.2 kernel.
In particular, this code is just broken:
===============================
linux-2.2.13/net/ipv4/af_inet.c:485
timeout = 0;
if (sk->linger && !(current->flags & PF_EXITING)) {
timeout = HZ * sk->lingertime;
if (!timeout)
timeout = MAX_SCHEDULE_TIMEOUT;
}
sock->sk = NULL;
sk->socket = NULL;
sk->prot->close(sk, timeout);
===============================
Unless anyone has a compelling reason for this behavior, I'd like to
propose the following patch. I hope that Alan and Dave can agree to put
this into the next 2.2 release:
===============================================
--- linux.orig/net/ipv4/af_inet.c Thu Feb 3 07:14:35 2000
+++ linux/net/ipv4/af_inet.c Fri Feb 4 19:30:47 2000
@@ -481,11 +481,30 @@
*
* If the close is due to the process exiting, we never
* linger..
+ *
+ * Previously, there was bad stuff here with timeouts.
+ * early 2.2 kernels would set timeout to be
+ * MAX_SCHED_TIMEOUT if lingertime was nonzero, or else
+ * set it to zero.
+ *
+ * Later, it was changed such that the actual timeout
+ * was used, unless it was zero, then MAX_SCHED_TIMEOUT
+ * was used.
+ *
+ * The latter behavior is really bad, as it causes an
+ * application setting lingertime to zero to block
+ * indefinately on close() -- definately _NOT_ what's
+ * intended, and not what any other stack does.
+ *
+ * Now, -1 is a sentinel for indefinate block on close,
+ * although I don't know why anyone would want that.
+ * Steve Kann, 4FEB00
+ *
*/
timeout = 0;
if (sk->linger && !(current->flags & PF_EXITING)) {
timeout = HZ * sk->lingertime;
- if (!timeout)
+ if (timeout == -1)
timeout = MAX_SCHEDULE_TIMEOUT;
}
sock->sk = NULL;
===============================================
Personally, I would probably just remove the conditional and assignment
altogether, and not give any way to get MAX_SCHEDULE_TIMEOUT, but since
negative values are undefined anyways it basically only costs the
conditional to allow that behavior.
-SteveK
-- Steve Kann - Horizon Live Distance Learning - 841 Broadway, Suite 502 P:stevek@SteveK.COM - B:stevek@HorizonLive.com - R:KC2FBU (212) 533-1775 "The box said 'Requires Windows 95, NT, or better,' so I installed Linux."- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Mon Feb 07 2000 - 21:00:12 EST