Hi,
The WIN2K and WINXP logs something like :
(32557)Socket is not connected: setsockopt(SO_UPDATE_ACCEPT_CONTEXT)
failed.
For almost each connection made.
Although this is not a fatal error, the setsockopt has no sense on the
socket that hasn't been accepted.
The patch calls the getsockopt and checks whether a connection has been
accepted and then calls the setsockopt to set the
SO_UPDATE_ACCEPT_CONTEXT.
MT.
Index: mpm_winnt.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/server/mpm/winnt/mpm_winnt.c,v
retrieving revision 1.195
diff -u -r1.195 mpm_winnt.c
--- mpm_winnt.c 2001/11/17 07:54:34 1.195
+++ mpm_winnt.c 2001/11/20 10:55:06
@@ -705,6 +705,7 @@
DWORD BytesRead;
SOCKET nlsd;
int lasterror;
+ apr_int32_t seconds, bytes = sizeof(seconds);
nlsd = (SOCKET) listen_socket;
@@ -728,16 +729,23 @@
if (pCompContext->accept_socket == INVALID_SOCKET) {
ap_log_error(APLOG_MARK,APLOG_ERR, apr_get_netos_error(),
ap_server_conf,
"winnt_accept: socket() failed. Process will exit.");
- // return -1;
}
-
- /* SO_UPDATE_ACCEPT_CONTEXT is required for shutdown() to work */
- if (setsockopt(pCompContext->accept_socket, SOL_SOCKET,
- SO_UPDATE_ACCEPT_CONTEXT, (char *)&nlsd,
- sizeof(nlsd))) {
- ap_log_error(APLOG_MARK, APLOG_WARNING, apr_get_netos_error(),
ap_server_conf,
- "setsockopt(SO_UPDATE_ACCEPT_CONTEXT) failed.");
- /* Not a failure condition. Keep running. */
+
+ /* Check whether a connection has been accepted and then
+ * inherit the properties of the socket listening socket.
+ * If the socket is not connected, the getsockopt returns 0xFFFFFFFF.
+ */
+ if (getsockopt(pCompContext->accept_socket, SOL_SOCKET,
+ SO_CONNECT_TIME, (char *)&seconds,
+ (apr_int32_t *)&bytes) != 0xFFFFFFFF) {
+ /* SO_UPDATE_ACCEPT_CONTEXT is required for shutdown() to work */
+ if (setsockopt(pCompContext->accept_socket, SOL_SOCKET,
+ SO_UPDATE_ACCEPT_CONTEXT, (char *)&nlsd,
+ sizeof(nlsd))) {
+ ap_log_error(APLOG_MARK, APLOG_WARNING, apr_get_netos_error(),
+ap_server_conf,
+ "setsockopt(SO_UPDATE_ACCEPT_CONTEXT) failed.");
+ /* Not a failure condition. Keep running. */
+ }
}
}