joes        2003/04/22 14:00:18

  Modified:    src      apreq_env.h apreq_params.c
  Log:
  Make apreq_request(ctx,NULL) semantics similar to apreq_jar(ctx,NULL).
  
  Revision  Changes    Path
  1.10      +1 -1      httpd-apreq-2/src/apreq_env.h
  
  Index: apreq_env.h
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/src/apreq_env.h,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- apreq_env.h       12 Apr 2003 15:42:11 -0000      1.9
  +++ apreq_env.h       22 Apr 2003 21:00:13 -0000      1.10
  @@ -89,7 +89,7 @@
   
   #define apreq_env_config(c) APREQ_ENV.config(c)
   
  -#define apreq_env_content_type(c) APREQ_ENV.in(c, "Content-Type");
  +#define apreq_env_content_type(c) APREQ_ENV.in(c, "Content-Type")
   #define apreq_env_cookie(c) APREQ_ENV.in(c, "Cookie")
   #define apreq_env_cookie2(c) APREQ_ENV.in(c, "Cookie2")
   #define apreq_env_set_cookie(c,s) APREQ_ENV.out(c,"Set-Cookie",s)
  
  
  
  1.12      +55 -43    httpd-apreq-2/src/apreq_params.c
  
  Index: apreq_params.c
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/src/apreq_params.c,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- apreq_params.c    21 Apr 2003 20:16:24 -0000      1.11
  +++ apreq_params.c    22 Apr 2003 21:00:13 -0000      1.12
  @@ -88,64 +88,76 @@
       return param;
   }
   
  +APR_INLINE
  +static const char * enctype(apr_pool_t *p, const char *ct)
  +{
  +    char *enctype, *semicolon;
  +    if (ct == NULL)
  +        enctype = NULL;
  +    else {
  +        enctype = apr_pstrdup(p, ct);
  +        semicolon = strchr(enctype, ';');
  +        if (semicolon)
  +            *semicolon = 0;
  +    }
  +    return enctype;
  +}
   
   APREQ_DECLARE(apreq_request_t *) apreq_request(void *ctx, const char *args)
   {
  -
  -    apreq_request_t *req, *old_req = apreq_env_request(ctx, NULL);
  -    const char *ct;
  -    apr_pool_t *p;
  +    apreq_request_t *req;
       apr_status_t s;
  -    dAPREQ_LOG;
   
  -    if (args == NULL && old_req != NULL)
  -        return old_req;
  +    if (args == NULL) {
  +        apreq_request_t *old_req = apreq_env_request(ctx,NULL);
  +        apr_pool_t *p;
   
  -    p = apreq_env_pool(ctx);
  -    req = apr_palloc(p, sizeof(apreq_table_t *) + sizeof *req);
  -    req->pool = p;
  -    *(apreq_table_t **)req->v.data = apreq_make_table(p, APREQ_NELTS);
  -    req->v.size   = sizeof(apreq_table_t *);
  -    req->v.status = APR_EINIT;
  -    req->env      = ctx;
  -    req->args     = apreq_make_table(p, APREQ_NELTS);
  -    req->body     = NULL;
  +        if (old_req != NULL)
  +            return old_req;
   
  -    ct = apreq_env_content_type(ctx);
  +        p = apreq_env_pool(ctx);
  +        args = apreq_env_args(ctx);
   
  -    if (ct == NULL)
  -        req->v.name = NULL;
  -    else {
  -        char *enctype = apr_pstrdup(p, ct);
  -        char *semicolon = strchr(enctype, ';');
  -        if (semicolon)
  -            *semicolon = 0;
  -        apreq_log(APREQ_DEBUG 0, ctx, "enctype: %s", enctype);
  -        req->v.name = enctype;
  -    }
  +        req = apr_palloc(p, sizeof(apreq_table_t *) + sizeof *req);
  +        req->pool = apreq_env_pool(ctx);
  +        *(apreq_table_t **)req->v.data = apreq_make_table(p, APREQ_NELTS);
  +        req->v.size   = sizeof(apreq_table_t *);
  +        req->v.status = APR_EINIT;
  +        req->env      = ctx;
  +        req->args     = apreq_make_table(p, APREQ_NELTS);
  +        req->body     = NULL;
  +        req->v.name = enctype(p, apreq_env_content_type(ctx));
  +        /* XXX need to install copy/merge callbacks for apreq_param_t */
  +
  +
  +        /* XXX get/set race condition here wrt apreq_env_request? */
  +        old_req = apreq_env_request(ctx, req);
  +        if (old_req != NULL) {
  +            apreq_env_request(ctx, old_req); /* reset old_req */
  +            return old_req;
  +        }
   
  -    /* XXX get/set race condition here wrt apreq_env_request.
  -     * apreq_env_request probably needs a write lock ???
  -     */
  -
  -    old_req = apreq_env_request(ctx, req);
  -
  -    if (old_req != NULL) {
  -        apreq_env_request(ctx, old_req); /* reset old_req */
  -        return old_req;
       }
  +    else {
  +        apr_pool_t *p = apreq_env_pool(ctx);
   
  -    /* XXX need to install copy/merge callbacks for apreq_param_t */
  -    req->pool = p;
  -
  -    if (args == NULL)
  -        args = apreq_env_args(ctx);
  +        req = apr_palloc(p, sizeof(apreq_table_t *) + sizeof *req);
  +        req->pool = apreq_env_pool(ctx);
  +        *(apreq_table_t **)req->v.data = apreq_make_table(p, APREQ_NELTS);
  +        req->v.size   = sizeof(apreq_table_t *);
  +        req->v.status = APR_EINIT;
  +        req->env      = ctx;
  +        req->args     = apreq_make_table(p, APREQ_NELTS);
  +        req->body     = NULL;
  +        req->v.name = enctype(p, apreq_env_content_type(ctx));
  +        /* XXX need to install copy/merge callbacks for apreq_param_t */
  +    }
   
       s = (args == NULL) ? APR_SUCCESS : 
  -        apreq_split_params(p, req->args, args);
  +        apreq_split_params(req->pool, req->args, args);
   
       if (s == APR_SUCCESS)
  -        req->v.status = ct ? APR_INCOMPLETE : APR_SUCCESS;
  +        req->v.status = (req->v.name ? APR_INCOMPLETE : APR_SUCCESS);
   
       return req;
   }
  
  
  

Reply via email to