httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject cvs commit: httpd-2.0/modules/arch/win32 mod_isapi.c
Date Sat, 09 Nov 2002 19:10:15 GMT
wrowe       2002/11/09 11:10:15

  Modified:    modules/arch/win32 mod_isapi.c
  Log:
    mod_isapi: Fix an issue where HSE_REQ_DONE_WITH_SESSION notification
    is received before the HttpExtensionProc() returns HSE_STATUS_PENDING.
    [John DeSetto <jdesetto@radiantsystems.com>, William Rowe]
  
  PR: 11918
  
  Revision  Changes    Path
  1.86      +46 -26    httpd-2.0/modules/arch/win32/mod_isapi.c
  
  Index: mod_isapi.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/arch/win32/mod_isapi.c,v
  retrieving revision 1.85
  retrieving revision 1.86
  diff -u -r1.85 -r1.86
  --- mod_isapi.c	4 Nov 2002 13:44:30 -0000	1.85
  +++ mod_isapi.c	9 Nov 2002 19:10:15 -0000	1.86
  @@ -892,9 +892,19 @@
            * leave it to the pool cleanup to dispose of our mutex.
            */
           if (cid->completed) {
  -            apr_thread_mutex_unlock(cid->completed);
  +            rv = apr_thread_mutex_create(&cid->completed, 
  +                                         APR_THREAD_MUTEX_UNNESTED, 
  +                                         r->pool);
  +            return 1;
           }
  -        return 1;
  +        else if (cid->dconf.log_unsupported) {
  +            ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r,
  +                          "ISAPI: ServerSupportFunction "
  +                          "HSE_REQ_DONE_WITH_SESSION is not supported: %s",
  +                          r->filename);
  +        }
  +        SetLastError(ERROR_INVALID_PARAMETER);
  +        return 0;
   
       case HSE_REQ_MAP_URL_TO_PATH:
       {
  @@ -1477,6 +1487,33 @@
           cid->ecb->lpbData = NULL;
       }
   
  +    /* To emulate async behavior...
  +     *
  +     * We create a cid->completed mutex and lock on it so that the
  +     * app can believe is it running async.
  +     *
  +     * This request completes upon a notification through
  +     * ServerSupportFunction(HSE_REQ_DONE_WITH_SESSION), which
  +     * unlocks this mutex.  If the HttpExtensionProc() returns
  +     * HSE_STATUS_PENDING, we will attempt to gain this lock again
  +     * which may *only* happen once HSE_REQ_DONE_WITH_SESSION has
  +     * unlocked the mutex.
  +     */
  +    if (cid->dconf.fake_async) {
  +        rv = apr_thread_mutex_create(&cid->completed, 
  +                                     APR_THREAD_MUTEX_UNNESTED, 
  +                                     r->pool);
  +        if (cid->completed && (rv == APR_SUCCESS)) {
  +            rv = apr_thread_mutex_lock(comp);
  +        }
  +
  +        if (!cid->completed || (rv != APR_SUCCESS)) {
  +            ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r,
  +                          "ISAPI: Failed to create completion mutex");
  +            return HTTP_INTERNAL_SERVER_ERROR;
  +        }
  +    }
  +
       /* All right... try and run the sucker */
       rv = (*isa->HttpExtensionProc)(cid->ecb);
   
  @@ -1501,32 +1538,15 @@
   
           case HSE_STATUS_PENDING:
               /* emulating async behavior...
  -             *
  -             * Create a cid->completed mutex and wait on it for some timeout
  -             * so that the app thinks is it running async.
  -             *
  -             * All async ServerSupportFunction calls will be handled through
  -             * the registered IO_COMPLETION hook.
  -             *
  -             * This request completes upon a notification through
  -             * ServerSupportFunction(HSE_REQ_DONE_WITH_SESSION)
                */
  -            if (cid->dconf.fake_async) {
  -                apr_thread_mutex_t *comp;
  -
  -                rv = apr_thread_mutex_create(&cid->completed, 
  -                                             APR_THREAD_MUTEX_UNNESTED, 
  -                                             r->pool);
  -                comp = cid->completed;
  -                if (cid->completed && (rv == APR_SUCCESS)) {
  -                    rv = apr_thread_mutex_lock(comp);
  -                }
  -                /* The completion port is now locked.  When we regain the
  -                 * lock, we may destroy the request.
  +            if (cid->completed) {
  +                /* The completion port was locked prior to invoking
  +                 * HttpExtensionProc().  Once we can regain the lock,
  +                 * when ServerSupportFunction(HSE_REQ_DONE_WITH_SESSION)
  +                 * is called by the extension to release the lock,
  +                 * we may finally destroy the request.
                    */
  -                if (cid->completed && (rv == APR_SUCCESS)) {
  -                    rv = apr_thread_mutex_lock(comp);
  -                }
  +                (void)apr_thread_mutex_lock(cid->completed);
                   break;
               }
               else if (cid->dconf.log_unsupported) {
  
  
  

Mime
View raw message