httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@apache.org
Subject cvs commit: httpd-2.0/server/mpm/experimental/perchild perchild.c
Date Fri, 25 Oct 2002 02:20:27 GMT
trawick     2002/10/24 19:20:27

  Modified:    .        CHANGES
               server/mpm/experimental/perchild perchild.c
  Log:
  fix some problems in the perchild MPM
  
  apr_socket_t ptr filled in by apr_os_sock_put() needs to be NULL on
  entry to have a new structure allocated
  
  various iov problems were fixed
  
  Submitted by:  Jonas Eriksson <jonas@webkonsulterna.com>
  Reviewed by:   Jeff Trawick
  
  Revision  Changes    Path
  1.960     +3 -0      httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.959
  retrieving revision 1.960
  diff -u -r1.959 -r1.960
  --- CHANGES	24 Oct 2002 15:47:31 -0000	1.959
  +++ CHANGES	25 Oct 2002 02:20:26 -0000	1.960
  @@ -1,5 +1,8 @@
   Changes with Apache 2.0.44
   
  +  *) Fix some problems in the perchild MPM.  
  +     [Jonas Eriksson <jonas@webkonsulterna.com>]
  +
     *) Change the CacheRoot processing to check for a required
        value at config time. This saves a lot of wasted processing
        if the mod_disk_cache module is loaded but no CacheRoot
  
  
  
  1.136     +27 -18    httpd-2.0/server/mpm/experimental/perchild/perchild.c
  
  Index: perchild.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/experimental/perchild/perchild.c,v
  retrieving revision 1.135
  retrieving revision 1.136
  diff -u -r1.135 -r1.136
  --- perchild.c	11 Oct 2002 15:41:52 -0000	1.135
  +++ perchild.c	25 Oct 2002 02:20:26 -0000	1.136
  @@ -679,9 +679,9 @@
   {
       struct msghdr msg;
       struct cmsghdr *cmsg;
  -    char headers[HUGE_STRING_LEN];
  -    char request_body[HUGE_STRING_LEN];
  -    struct iovec iov[2];
  +    char buffer[HUGE_STRING_LEN * 2], *headers, *body;
  +    int headerslen, bodylen;
  +    struct iovec iov;
       int ret, dp;
       apr_os_sock_t sd;
       apr_bucket_alloc_t *alloc = apr_bucket_alloc_create(ptrans);
  @@ -690,15 +690,13 @@
   
       apr_os_sock_get(&sd, lr->sd);
   
  -    iov[0].iov_base = headers;
  -    iov[0].iov_len = HUGE_STRING_LEN;
  -    iov[1].iov_base = request_body;
  -    iov[1].iov_len = HUGE_STRING_LEN;
  +    iov.iov_base = buffer;
  +    iov.iov_len = sizeof(buffer);
   
       msg.msg_name = NULL;
       msg.msg_namelen = 0;
  -    msg.msg_iov = iov;
  -    msg.msg_iovlen = 2;
  +    msg.msg_iov = &iov;
  +    msg.msg_iovlen = 1;
   
       cmsg = apr_palloc(ptrans, sizeof(*cmsg) + sizeof(sd));
       cmsg->cmsg_len = sizeof(*cmsg) + sizeof(sd);
  @@ -709,20 +707,32 @@
   
       memcpy(&dp, CMSG_DATA(cmsg), sizeof(dp));
   
  +    *csd = NULL; /* tell apr_os_sock_put() to allocate new apr_socket_t */
       apr_os_sock_put((apr_socket_t **)csd, &dp, ptrans);
   
       bucket = apr_bucket_eos_create(alloc);
       APR_BRIGADE_INSERT_HEAD(bb, bucket);
       bucket = apr_bucket_socket_create(*csd, alloc);
       APR_BRIGADE_INSERT_HEAD(bb, bucket);
  -    bucket = apr_bucket_heap_create(iov[1].iov_base, 
  -                                    iov[1].iov_len, NULL, alloc);
  +
  +    body = strchr(iov.iov_base, 0);
  +    if (!body) {
  +        return 1;
  +    }
  +
  +    body++;
  +    bodylen = strlen(body);
  +
  +    headers = iov.iov_base;
  +    headerslen = body - headers;
  +
  +    bucket = apr_bucket_heap_create(body, bodylen, NULL, alloc);
       APR_BRIGADE_INSERT_HEAD(bb, bucket);
  -    bucket = apr_bucket_heap_create(iov[0].iov_base, 
  -                                    iov[0].iov_len, NULL, alloc);
  +    bucket = apr_bucket_heap_create(headers, headerslen, NULL, alloc);
       APR_BRIGADE_INSERT_HEAD(bb, bucket);
   
       apr_pool_userdata_set(bb, "PERCHILD_SOCKETS", NULL, ptrans);
  +
       return 0;
   }
   
  @@ -730,7 +740,7 @@
   
   static void *worker_thread(apr_thread_t *thd, void *arg)
   {
  -    void *csd = NULL;
  +    void *csd;
       apr_pool_t *tpool;      /* Pool for this thread           */
       apr_pool_t *ptrans;     /* Pool for per-transaction stuff */
       volatile int thread_just_started = 1;
  @@ -1635,8 +1645,7 @@
       apr_bucket_brigade *bb = apr_brigade_create(r->pool, c->bucket_alloc);
       apr_bucket_brigade *sockbb;
       char request_body[HUGE_STRING_LEN] = "\0";
  -    apr_off_t len = 0;
  -    apr_size_t l = 0;
  +    apr_size_t l = sizeof(request_body);
       perchild_header h;
       apr_bucket *sockbuck;
       perchild_server_conf *sconf = (perchild_server_conf *)
  @@ -1647,7 +1656,7 @@
                    "passing request to another child.  Vhost: %s, child %d %d",
                    apr_table_get(r->headers_in, "Host"), child_num, sconf->output);
       ap_get_brigade(r->connection->input_filters, bb, AP_MODE_EXHAUSTIVE, APR_NONBLOCK_READ,
  -                   len);
  +                   0);
   
       for (sockbuck = APR_BRIGADE_FIRST(bb); sockbuck != APR_BRIGADE_SENTINEL(bb);
            sockbuck = APR_BUCKET_NEXT(sockbuck)) {
  @@ -1678,7 +1687,7 @@
       iov[0].iov_base = h.headers;
       iov[0].iov_len = strlen(h.headers) + 1;
       iov[1].iov_base = request_body;
  -    iov[1].iov_len = len + 1;
  +    iov[1].iov_len = l + 1;
   
       msg.msg_name = NULL;
       msg.msg_namelen = 0;
  
  
  

Mime
View raw message