]> granicus.if.org Git - apache/commitdiff
mpm_winnt: clear OVERLAPPED structs before reuse
authorJacob Champion <jchampion@apache.org>
Mon, 29 Aug 2016 23:56:21 +0000 (23:56 +0000)
committerJacob Champion <jchampion@apache.org>
Mon, 29 Aug 2016 23:56:21 +0000 (23:56 +0000)
MSDN documentation states that

    Any unused members of [an OVERLAPPED] structure should always be
    initialized to zero before the structure is used in a function call.
    Otherwise, the function may fail and return ERROR_INVALID_PARAMETER.

Prior to this patch, the internal state left over from previous
overlapped I/O was passed into the next call. It's unclear what effect
this might have, if any. (I have not personally witnessed an
ERROR_INVALID_PARAMETER myself.)

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1758310 13f79535-47bb-0310-9956-ffa450edef68

server/mpm/winnt/child.c

index 63aa81f931b0c0a9730a7652564c1e1a6cefec98..6f9625b421409c1587b33c75a9be6cf576befc25 100644 (file)
@@ -136,10 +136,17 @@ static void mpm_recycle_completion_context(winnt_conn_ctx_t *context)
      * state so -don't- close it.
      */
     if (context) {
+        HANDLE saved_event;
+
         apr_pool_clear(context->ptrans);
         context->ba = apr_bucket_alloc_create(context->ptrans);
         context->next = NULL;
+
+        saved_event = context->overlapped.hEvent;
+        memset(&context->overlapped, 0, sizeof(context->overlapped));
+        context->overlapped.hEvent = saved_event;
         ResetEvent(context->overlapped.hEvent);
+
         apr_thread_mutex_lock(qlock);
         if (qtail) {
             qtail->next = context;