httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@locus.apache.org
Subject cvs commit: apache-2.0/src/ap ap_buckets_socket.c Makefile.in
Date Tue, 10 Oct 2000 22:09:27 GMT
rbb         00/10/10 15:09:26

  Modified:    src/include ap_buckets.h
               src/ap   Makefile.in
  Added:       src/ap   ap_buckets_socket.c
  Log:
  First cut at a socket bucket type.  Not tested yet, but it's really just
  a copy of a pipe bucket, so it should be okay.  I am currently working on
  getting input filters to use it.
  
  Revision  Changes    Path
  1.32      +10 -0     apache-2.0/src/include/ap_buckets.h
  
  Index: ap_buckets.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/include/ap_buckets.h,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- ap_buckets.h	2000/10/02 00:43:32	1.31
  +++ ap_buckets.h	2000/10/10 22:09:23	1.32
  @@ -128,6 +128,7 @@
       AP_BUCKET_MMAP,
       AP_BUCKET_IMMORTAL,
       AP_BUCKET_POOL,
  +    AP_BUCKET_SOCKET,
       AP_BUCKET_PIPE,
       AP_BUCKET_EOS        /* End-of-stream bucket.  Special case to say this is
                             * the end of the brigade so all data should be sent
  @@ -606,6 +607,15 @@
   		apr_mmap_t *mm, apr_off_t start, apr_size_t length);
   API_EXPORT(ap_bucket *) ap_bucket_make_mmap(ap_bucket *b,
   		apr_mmap_t *mm, apr_off_t start, apr_size_t length);
  +
  +/**
  + * Create a bucket referring to a socket.
  + * @param thissocket The socket to put in the bucket
  + * @return The new bucket, or NULL if allocation failed
  + * @deffunc ap_bucket *ap_bucket_create_socket(apr_socket_t *thissocket)
  + */
  +API_EXPORT(ap_bucket *) ap_bucket_create_socket(apr_socket_t *thissock);
  +API_EXPORT(ap_bucket *) ap_bucket_make_socket(ap_bucket *b, apr_socket_t *thissock);
   
   /**
    * Create a bucket referring to a pipe.
  
  
  
  1.11      +2 -1      apache-2.0/src/ap/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/ap/Makefile.in,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- Makefile.in	2000/09/21 17:04:33	1.10
  +++ Makefile.in	2000/10/10 22:09:25	1.11
  @@ -2,6 +2,7 @@
   LTLIBRARY_NAME    = libap.la
   LTLIBRARY_SOURCES = ap_cache.c ap_base64.c ap_sha1.c ap_hooks.c ap_buckets.c \
   	ap_buckets_eos.c ap_buckets_simple.c ap_buckets_refcount.c \
  -	ap_buckets_heap.c ap_buckets_mmap.c ap_buckets_pipe.c ap_buckets_file.c
  +	ap_buckets_heap.c ap_buckets_mmap.c ap_buckets_pipe.c \
  +	ap_buckets_file.c ap_buckets_socket.c
   
   include $(top_srcdir)/build/ltlib.mk
  
  
  
  1.1                  apache-2.0/src/ap/ap_buckets_socket.c
  
  Index: ap_buckets_socket.c
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  #include "apr_private.h"
  #include "httpd.h"
  #include "ap_buckets.h"
  #include <stdlib.h>
  
  /* XXX: We should obey the block flag */
  static apr_status_t socket_read(ap_bucket *a, const char **str,
  			      apr_ssize_t *len, int block)
  {
      apr_socket_t *p = a->data;
      ap_bucket *b;
      char *buf;
      apr_status_t rv;
  
      buf = malloc(IOBUFSIZE); /* XXX: check for failure? */
      *str = buf;
      *len = IOBUFSIZE;
      rv = apr_recv(p, buf, len);
      if (rv != APR_SUCCESS && rv != APR_EOF) {
  	free(buf);
          return rv;
      }
      /*
       * Change the current bucket to refer to what we read,
       * even if we read nothing because we hit EOF.
       */
      ap_bucket_make_heap(a, buf, *len, 0, NULL);  /* XXX: check for failure? */
      /*
       * If there's more to read we have to keep the rest of the socket
       * for later. XXX: Note that more complicated bucket types that
       * refer to data not in memory and must therefore have a read()
       * function similar to this one should be wary of copying this
       * code because if they have a destroy function they probably
       * want to migrate the bucket's subordinate structure from the
       * old bucket to a raw new one and adjust it as appropriate,
       * rather than destroying the old one and creating a completely
       * new bucket.
       */
      if (*len > 0) {
          b = ap_bucket_create_socket(p);
  	AP_BUCKET_INSERT_AFTER(a, b);
      }
      return APR_SUCCESS;
  }
  
  API_EXPORT(ap_bucket *) ap_bucket_make_socket(ap_bucket *b, apr_socket_t *p)
  {
      /*
       * XXX: We rely on a cleanup on some pool or other to actually
       * destroy the socket. We should probably explicitly call apr to
       * destroy it instead.
       *
       * Note that typically the socket is allocated from the connection pool
       * so it will disappear when the connection is finished. 
       */
      b->type     = AP_BUCKET_SOCKET;
      b->length   = -1;
      b->setaside = NULL;
      b->destroy  = NULL;
      b->split    = NULL;
      b->read     = socket_read;
      b->data     = p;
  
      return b;
  }
  
  API_EXPORT(ap_bucket *) ap_bucket_create_socket(apr_socket_t *p)
  {
      ap_bucket_do_create(ap_bucket_make_socket(b, p));
  }
  
  
  

Mime
View raw message