apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@apache.org
Subject cvs commit: apr/poll/unix pollacc.c Makefile.in poll.c
Date Thu, 11 Jul 2002 15:32:18 GMT
rbb         2002/07/11 08:32:18

  Modified:    .        apr.dsp libapr.dsp
               poll/os2 Makefile.in
               poll/unix Makefile.in poll.c
  Added:       poll/os2 pollacc.c
               poll/unix pollacc.c
  Log:
  Split the apr_poll() implementation from the accessor functions.  This
  allows all platforms to use the same implementation for the accessor
  functions.
  Submitted by:	Brian Havard
  
  Revision  Changes    Path
  1.107     +4 -0      apr/apr.dsp
  
  Index: apr.dsp
  ===================================================================
  RCS file: /home/cvs/apr/apr.dsp,v
  retrieving revision 1.106
  retrieving revision 1.107
  diff -u -r1.106 -r1.107
  --- apr.dsp	11 Jul 2002 06:25:28 -0000	1.106
  +++ apr.dsp	11 Jul 2002 15:32:17 -0000	1.107
  @@ -266,6 +266,10 @@
   # End Source File
   # Begin Source File
   
  +SOURCE=.\poll\unix\pollacc.c
  +# End Source File
  +# Begin Source File
  +
   SOURCE=.\poll\unix\poll.c
   # End Source File
   # Begin Source File
  
  
  
  1.68      +4 -0      apr/libapr.dsp
  
  Index: libapr.dsp
  ===================================================================
  RCS file: /home/cvs/apr/libapr.dsp,v
  retrieving revision 1.67
  retrieving revision 1.68
  diff -u -r1.67 -r1.68
  --- libapr.dsp	11 Jul 2002 06:25:28 -0000	1.67
  +++ libapr.dsp	11 Jul 2002 15:32:17 -0000	1.68
  @@ -272,6 +272,10 @@
   # End Source File
   # Begin Source File
   
  +SOURCE=.\poll\unix\pollacc.c
  +# End Source File
  +# Begin Source File
  +
   SOURCE=.\poll\unix\poll.c
   # End Source File
   # Begin Source File
  
  
  
  1.2       +2 -1      apr/poll/os2/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  RCS file: /home/cvs/apr/poll/os2/Makefile.in,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Makefile.in	11 Jul 2002 05:40:23 -0000	1.1
  +++ Makefile.in	11 Jul 2002 15:32:18 -0000	1.2
  @@ -2,7 +2,8 @@
   VPATH = @srcdir@
   
   TARGETS = \
  -	poll.lo 
  +	poll.lo \
  +	pollacc.lo
   
   # bring in rules.mk for standard functionality
   @INCLUDE_RULES@
  
  
  
  1.1                  apr/poll/os2/pollacc.c
  
  Index: pollacc.c
  ===================================================================
  #include "../unix/pollacc.c"
  
  
  
  1.2       +3 -1      apr/poll/unix/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  RCS file: /home/cvs/apr/poll/unix/Makefile.in,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Makefile.in	11 Jul 2002 05:19:45 -0000	1.1
  +++ Makefile.in	11 Jul 2002 15:32:18 -0000	1.2
  @@ -2,7 +2,9 @@
   VPATH = @srcdir@
   
   TARGETS = \
  -	poll.lo 
  +	poll.lo \
  +	pollacc.lo 
  +
   
   # bring in rules.mk for standard functionality
   @INCLUDE_RULES@
  
  
  
  1.5       +2 -110    apr/poll/unix/poll.c
  
  Index: poll.c
  ===================================================================
  RCS file: /home/cvs/apr/poll/unix/poll.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- poll.c	11 Jul 2002 14:39:04 -0000	1.4
  +++ poll.c	11 Jul 2002 15:32:18 -0000	1.5
  @@ -63,99 +63,6 @@
   #include <sys/poll.h>
   #endif
   
  -APR_DECLARE(apr_status_t) apr_poll_setup(apr_pollfd_t **new, apr_int32_t num, apr_pool_t
*cont)
  -{
  -    (*new) = (apr_pollfd_t *)apr_pcalloc(cont, sizeof(apr_pollfd_t) * (num + 1));
  -    if ((*new) == NULL) {
  -        return APR_ENOMEM;
  -    }
  -    (*new)[num].desc_type = APR_POLL_LASTDESC;
  -    (*new)[0].p = cont;
  -    return APR_SUCCESS;
  -}
  -
  -APR_DECLARE(apr_pollfd_t*) find_poll_sock(apr_pollfd_t *aprset, apr_socket_t *sock)
  -{
  -    apr_pollfd_t *curr = aprset;
  -    
  -    while (curr->desc.s != sock) {
  -        if (curr->desc_type == APR_POLL_LASTDESC) {
  -            return NULL;
  -        }
  -        curr++;
  -    }
  -
  -    return curr;
  -}
  -
  -APR_DECLARE(apr_status_t) apr_poll_socket_add(apr_pollfd_t *aprset, 
  -			       apr_socket_t *sock, apr_int16_t event)
  -{
  -    apr_pollfd_t *curr = aprset;
  -    
  -    while (curr->desc_type != APR_NO_DESC) {
  -        if (curr->desc_type == APR_POLL_LASTDESC) {
  -            return APR_ENOMEM;
  -        }
  -        curr++;
  -    }
  -    curr->desc.s = sock;
  -    curr->desc_type = APR_POLL_SOCKET;
  -    curr->reqevents = event;
  -
  -    return APR_SUCCESS;
  -}
  -
  -APR_DECLARE(apr_status_t) apr_poll_revents_get(apr_int16_t *event, apr_socket_t *sock,
apr_pollfd_t *aprset)
  -{
  -    apr_pollfd_t *curr = find_poll_sock(aprset, sock);
  -    if (curr == NULL) {
  -        return APR_NOTFOUND;
  -    }
  -
  -    (*event) = curr->revents;
  -    return APR_SUCCESS;
  -}
  -
  -APR_DECLARE(apr_status_t) apr_poll_socket_mask(apr_pollfd_t *aprset, 
  -                                  apr_socket_t *sock, apr_int16_t events)
  -{
  -    apr_pollfd_t *curr = find_poll_sock(aprset, sock);
  -    if (curr == NULL) {
  -        return APR_NOTFOUND;
  -    }
  -    
  -    if (curr->reqevents & events) {
  -        curr->reqevents ^= events;
  -    }
  -
  -    return APR_SUCCESS;
  -}
  -
  -APR_DECLARE(apr_status_t) apr_poll_socket_remove(apr_pollfd_t *aprset, apr_socket_t *sock)
  -{
  -    apr_pollfd_t *curr = find_poll_sock(aprset, sock);
  -    if (curr == NULL) {
  -        return APR_NOTFOUND;
  -    }
  -
  -    curr->desc_type = APR_NO_DESC;
  -
  -    return APR_SUCCESS;
  -}
  -
  -APR_DECLARE(apr_status_t) apr_poll_socket_clear(apr_pollfd_t *aprset, apr_int16_t events)
  -{
  -    apr_pollfd_t *curr = aprset;
  -
  -    while (curr->desc_type != APR_POLL_LASTDESC) {
  -        if (curr->events & events) {
  -            curr->events &= ~events;
  -        }
  -    }
  -    return APR_SUCCESS;
  -}
  -
   #ifdef HAVE_POLL    /* We can just use poll to do our socket polling. */
   
   static apr_int16_t get_event(apr_int16_t event)
  @@ -216,7 +123,7 @@
           else if (aprset[i].desc_type == APR_POLL_FILE) {
               pollset[i].fd = aprset[i].desc.f->filedes;
           }
  -        pollset[i].events = get_event(aprset[i].events);
  +        pollset[i].events = get_event(aprset[i].reqevents);
       }
   
       if (timeout > 0) {
  @@ -227,7 +134,7 @@
       (*nsds) = i;
   
       for (i = 0; i < num; i++) {
  -        aprset[i].revents = get_revent(pollset[i].revents);
  +        aprset[i].rtnevents = get_revent(pollset[i].revents);
       }
       
       if ((*nsds) < 0) {
  @@ -322,18 +229,3 @@
   }
   
   #endif 
  -
  -#if APR_FILES_AS_SOCKETS
  -/* I'm not sure if this needs to return an apr_status_t or not, but
  - * for right now, we'll leave it this way, and change it later if
  - * necessary.
  - */
  -APR_DECLARE(apr_status_t) apr_socket_from_file(apr_socket_t **newsock, apr_file_t *file)
  -{
  -    (*newsock) = apr_pcalloc(file->pool, sizeof(**newsock));
  -    (*newsock)->socketdes = file->filedes;
  -    (*newsock)->cntxt = file->pool;
  -    (*newsock)->timeout = file->timeout;
  -    return APR_SUCCESS;
  -}
  -#endif
  
  
  
  1.1                  apr/poll/unix/pollacc.c
  
  Index: pollacc.c
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2002 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.h"
  #include "apr_poll.h"
  #include "networkio.h"
  #include "fileio.h"
  #if HAVE_POLL_H
  #include <poll.h>
  #endif
  #if HAVE_SYS_POLL_H
  #include <sys/poll.h>
  #endif
  
  APR_DECLARE(apr_status_t) apr_poll_setup(apr_pollfd_t **new, apr_int32_t num, apr_pool_t
*cont)
  {
      (*new) = (apr_pollfd_t *)apr_pcalloc(cont, sizeof(apr_pollfd_t) * (num + 1));
      if ((*new) == NULL) {
          return APR_ENOMEM;
      }
      (*new)[num].desc_type = APR_POLL_LASTDESC;
      (*new)[0].p = cont;
      return APR_SUCCESS;
  }
  
  APR_DECLARE(apr_pollfd_t*) find_poll_sock(apr_pollfd_t *aprset, apr_socket_t *sock)
  {
      apr_pollfd_t *curr = aprset;
      
      while (curr->desc.s != sock) {
          if (curr->desc_type == APR_POLL_LASTDESC) {
              return NULL;
          }
          curr++;
      }
  
      return curr;
  }
  
  APR_DECLARE(apr_status_t) apr_poll_socket_add(apr_pollfd_t *aprset, 
  			       apr_socket_t *sock, apr_int16_t event)
  {
      apr_pollfd_t *curr = aprset;
      
      while (curr->desc_type != APR_NO_DESC) {
          if (curr->desc_type == APR_POLL_LASTDESC) {
              return APR_ENOMEM;
          }
          curr++;
      }
      curr->desc.s = sock;
      curr->desc_type = APR_POLL_SOCKET;
      curr->reqevents = event;
  
      return APR_SUCCESS;
  }
  
  APR_DECLARE(apr_status_t) apr_poll_revents_get(apr_int16_t *event, apr_socket_t *sock, apr_pollfd_t
*aprset)
  {
      apr_pollfd_t *curr = find_poll_sock(aprset, sock);
      if (curr == NULL) {
          return APR_NOTFOUND;
      }
  
      (*event) = curr->rtnevents;
      return APR_SUCCESS;
  }
  
  APR_DECLARE(apr_status_t) apr_poll_socket_mask(apr_pollfd_t *aprset, 
                                    apr_socket_t *sock, apr_int16_t events)
  {
      apr_pollfd_t *curr = find_poll_sock(aprset, sock);
      if (curr == NULL) {
          return APR_NOTFOUND;
      }
      
      if (curr->reqevents & events) {
          curr->reqevents ^= events;
      }
  
      return APR_SUCCESS;
  }
  
  APR_DECLARE(apr_status_t) apr_poll_socket_remove(apr_pollfd_t *aprset, apr_socket_t *sock)
  {
      apr_pollfd_t *curr = find_poll_sock(aprset, sock);
      if (curr == NULL) {
          return APR_NOTFOUND;
      }
  
      curr->desc_type = APR_NO_DESC;
  
      return APR_SUCCESS;
  }
  
  APR_DECLARE(apr_status_t) apr_poll_socket_clear(apr_pollfd_t *aprset, apr_int16_t events)
  {
      apr_pollfd_t *curr = aprset;
  
      while (curr->desc_type != APR_POLL_LASTDESC) {
          if (curr->reqevents & events) {
              curr->reqevents &= ~events;
          }
      }
      return APR_SUCCESS;
  }
  
  #if APR_FILES_AS_SOCKETS
  /* I'm not sure if this needs to return an apr_status_t or not, but
   * for right now, we'll leave it this way, and change it later if
   * necessary.
   */
  APR_DECLARE(apr_status_t) apr_socket_from_file(apr_socket_t **newsock, apr_file_t *file)
  {
      (*newsock) = apr_pcalloc(file->pool, sizeof(**newsock));
      (*newsock)->socketdes = file->filedes;
      (*newsock)->cntxt = file->pool;
      (*newsock)->timeout = file->timeout;
      return APR_SUCCESS;
  }
  #endif
  
  
  

Mime
View raw message