From: Gregg Lewis Smith Date: Mon, 7 Oct 2013 20:02:48 +0000 (+0000) Subject: Merge r1529449 from trunk: X-Git-Tag: 2.4.7~132 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1b7f660927fff9e08269dc439269bd42ef667f52;p=apache Merge r1529449 from trunk: * WinNT MPM: Follow MS docs on AcceptEx/GetAcceptExSockaddrs Submitted By: trawick Reviewed By: covener, gsmith git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1530045 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/STATUS b/STATUS index bffc15985f..bbeb7b6857 100644 --- a/STATUS +++ b/STATUS @@ -97,11 +97,6 @@ RELEASE SHOWSTOPPERS: PATCHES ACCEPTED TO BACKPORT FROM TRUNK: [ start all new proposals below, under PATCHES PROPOSED. ] - * WinNT MPM: Follow MS docs on AcceptEx/GetAcceptExSockaddrs - trunk patch: https://svn.apache.org/r1363312 - 2.4.x: trunk patch works - +1: trawick, covener, gsmith - PATCHES PROPOSED TO BACKPORT FROM TRUNK: [ New proposals should be added at the end of the list ] diff --git a/server/mpm/winnt/child.c b/server/mpm/winnt/child.c index 7bfe53cd3f..d350dd79e4 100644 --- a/server/mpm/winnt/child.c +++ b/server/mpm/winnt/child.c @@ -45,7 +45,22 @@ #ifdef __MINGW32__ #include -#endif + +#ifndef WSAID_ACCEPTEX +#define WSAID_ACCEPTEX \ + {0xb5367df1, 0xcbac, 0x11cf, {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}} +typedef BOOL (WINAPI *LPFN_ACCEPTEX)(SOCKET, SOCKET, PVOID, DWORD, DWORD, DWORD, LPDWORD, LPOVERLAPPED); +#endif /* WSAID_ACCEPTEX */ + +#ifndef WSAID_GETACCEPTEXSOCKADDRS +#define WSAID_GETACCEPTEXSOCKADDRS \ + {0xb5367df2, 0xcbac, 0x11cf, {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}} +typedef VOID (WINAPI *LPFN_GETACCEPTEXSOCKADDRS)(PVOID, DWORD, DWORD, DWORD, + struct sockaddr **, LPINT, + struct sockaddr **, LPINT); +#endif /* WSAID_GETACCEPTEXSOCKADDRS */ + +#endif /* __MINGW32__ */ /* * The Windows MPM uses a queue of completion contexts that it passes @@ -281,6 +296,10 @@ static unsigned int __stdcall winnt_accept(void *lr_) winnt_conn_ctx_t *context = NULL; DWORD BytesRead; SOCKET nlsd; + LPFN_ACCEPTEX lpfnAcceptEx = NULL; + LPFN_GETACCEPTEXSOCKADDRS lpfnGetAcceptExSockaddrs = NULL; + GUID GuidAcceptEx = WSAID_ACCEPTEX; + GUID GuidGetAcceptExSockaddrs = WSAID_GETACCEPTEXSOCKADDRS; core_server_config *core_sconf; const char *accf_name; int rv; @@ -333,6 +352,24 @@ static unsigned int __stdcall winnt_accept(void *lr_) if (accf > 0) /* 'data' or 'connect' */ { + if (WSAIoctl(nlsd, SIO_GET_EXTENSION_FUNCTION_POINTER, + &GuidAcceptEx, sizeof GuidAcceptEx, + &lpfnAcceptEx, sizeof lpfnAcceptEx, + &BytesRead, NULL, NULL) == SOCKET_ERROR) { + ap_log_error(APLOG_MARK, APLOG_ERR, apr_get_netos_error(), + ap_server_conf, APLOGNO(02322) + "winnt_accept: failed to retrieve AcceptEx, try 'AcceptFilter none'"); + return 1; + } + if (WSAIoctl(nlsd, SIO_GET_EXTENSION_FUNCTION_POINTER, + &GuidGetAcceptExSockaddrs, sizeof GuidGetAcceptExSockaddrs, + &lpfnGetAcceptExSockaddrs, sizeof lpfnGetAcceptExSockaddrs, + &BytesRead, NULL, NULL) == SOCKET_ERROR) { + ap_log_error(APLOG_MARK, APLOG_ERR, apr_get_netos_error(), + ap_server_conf, APLOGNO(02323) + "winnt_accept: failed to retrieve GetAcceptExSockaddrs, try 'AcceptFilter none'"); + return 1; + } /* first, high priority event is an already accepted connection */ events[1] = exit_event; events[2] = max_requests_per_child_event; @@ -429,9 +466,9 @@ reinit: /* target of data or connect upon too many AcceptEx failures */ /* AcceptEx on the completion context. The completion context will be * signaled when a connection is accepted. */ - if (!AcceptEx(nlsd, context->accept_socket, buf, len, - PADDED_ADDR_SIZE, PADDED_ADDR_SIZE, &BytesRead, - &context->overlapped)) { + if (!lpfnAcceptEx(nlsd, context->accept_socket, buf, len, + PADDED_ADDR_SIZE, PADDED_ADDR_SIZE, &BytesRead, + &context->overlapped)) { rv = apr_get_netos_error(); if ((rv == APR_FROM_OS_ERROR(WSAECONNRESET)) || (rv == APR_FROM_OS_ERROR(WSAEACCES))) { @@ -548,9 +585,9 @@ reinit: /* target of data or connect upon too many AcceptEx failures */ /* Get the local & remote address * TODO; error check */ - GetAcceptExSockaddrs(buf, len, PADDED_ADDR_SIZE, PADDED_ADDR_SIZE, - &context->sa_server, &context->sa_server_len, - &context->sa_client, &context->sa_client_len); + lpfnGetAcceptExSockaddrs(buf, len, PADDED_ADDR_SIZE, PADDED_ADDR_SIZE, + &context->sa_server, &context->sa_server_len, + &context->sa_client, &context->sa_client_len); /* For 'data', craft a bucket for our data result * and pass to worker_main as context->overlapped.Pointer