apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject cvs commit: apr/network_io/win32 sockets.c
Date Mon, 16 Jul 2001 18:14:25 GMT
wrowe       01/07/16 11:14:25

  Modified:    include  apr_inherit.h apr_network_io.h
               network_io/unix sockets.c
               network_io/win32 sockets.c
  Log:
    Change 'inherit' to a usual flags value, use 2^24 for the first rather
    global switch value.  We may have more (APR_THREAD_SAFE, anyone?) that
    are very consistent from type to type, pick those up from 2^25.
  
  Revision  Changes    Path
  1.2       +14 -10    apr/include/apr_inherit.h
  
  Index: apr_inherit.h
  ===================================================================
  RCS file: /home/cvs/apr/include/apr_inherit.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- apr_inherit.h	2001/07/16 16:11:03	1.1
  +++ apr_inherit.h	2001/07/16 18:14:20	1.2
  @@ -60,28 +60,32 @@
   #endif /* __cplusplus */
   
   #define APR_NO_INHERIT 0
  -#define APR_INHERIT    1
  +#define APR_INHERIT    (2^24)    /* Outside of conflicts with other bits */
   
   #define APR_DECLARE_SET_INHERIT(name) \
       void apr_##name##_set_inherit(apr_##name##_t *name)
   
  -#define APR_SET_INHERIT(name, pool, cleanup, field_exists)          \
  +#define APR_IMPLEMENT_SET_INHERIT(name, pool, cleanup)              \
   void apr_##name##_set_inherit(apr_##name##_t *name)                 \
   {                                                                   \
  -    name->inherit = 1;                                              \
  -    apr_pool_cleanup_register(name->##pool, (void *)##name##, NULL, \
  -                              cleanup);                             \
  +    if (!name->inherit) {                                           \
  +        name->inherit = 1;                                          \
  +        apr_pool_cleanup_register(name->##pool, (void *)##name##,   \
  +                                  NULL, cleanup);                   \
  +    }                                                               \
   }
   
   #define APR_DECLARE_UNSET_INHERIT(name) \
       void apr_##name##_unset_inherit(apr_##name##_t *name)
   
  -#define APR_UNSET_INHERIT(name, pool, cleanup, field_exists)          \
  -void apr_##name##_unset_inherit(apr_##name##_t *name)                 \
  +#define APR_IMPLEMENT_UNSET_INHERIT(name, pool, cleanup)            \
  +void apr_##name##_unset_inherit(apr_##name##_t *name)               \
   {                                                                   \
  -    name->inherit = 0;                                              \
  -    apr_pool_cleanup_kill(name->##pool, (void *)##name##, NULL, \
  -                              cleanup);                             \
  +    if (name->inherit) {                                            \
  +        name->inherit = 0;                                          \
  +        apr_pool_cleanup_kill(name->##pool, (void *)##name##,       \
  +                              NULL, cleanup);                       \
  +    }                                                               \
   }
   
   #ifdef __cplusplus
  
  
  
  1.104     +23 -3     apr/include/apr_network_io.h
  
  Index: apr_network_io.h
  ===================================================================
  RCS file: /home/cvs/apr/include/apr_network_io.h,v
  retrieving revision 1.103
  retrieving revision 1.104
  diff -u -r1.103 -r1.104
  --- apr_network_io.h	2001/07/16 16:11:03	1.103
  +++ apr_network_io.h	2001/07/16 18:14:20	1.104
  @@ -241,13 +241,17 @@
    * @param new_sock The new socket that has been set up.
    * @param family The address family of the socket (e.g., APR_INET).
    * @param type The type of the socket (e.g., SOCK_STREAM).
  - * @param inherit Should this socket be inherited by child processes
  + * @param flag Should this socket be inherited by child processes.  One of
  + * <PRE>
  + *          APR_INHERIT       This socket is inherited by children
  + *          APR_NO_INHERIT    This socket is not inherited by children.
  + * </PRE>
    * @param cont The pool to use
  - * @deffunc apr_status_t apr_socket_create(apr_socket_t **new_sock, int family, int type,
apr_pool_t *cont)
  + * @deffunc apr_status_t apr_socket_create(apr_socket_t **new_sock, int family, int type,
apr_int32_t flag, apr_pool_t *cont)
    */
   APR_DECLARE(apr_status_t) apr_socket_create(apr_socket_t **new_sock, 
                                               int family, int type,
  -                                            int inherit, apr_pool_t *cont);
  +                                            apr_int32_t flag, apr_pool_t *cont);
   
   /**
    * Shutdown either reading, writing, or both sides of a tcp socket.
  @@ -803,7 +807,23 @@
                                         char args[256 - 16]);
   #endif
   
  +/**
  + * Set a socket to be inherited by child processes.
  + * @param socket The socket to enable inheritance.
  + * @deffunc void apr_socket_set_inherit(apr_socket_t *socket)
  + * @tip Same effect as passing the APR_INHERIT flag to apr_socket_create(),
  + * but it is far more efficient to pass the correct value in the first place.
  + */
   APR_DECLARE_SET_INHERIT(socket);
  +
  +/**
  + * Unset a socket from being inherited by child processes.
  + * @param socket The socket to disable inheritance.
  + * @deffunc void apr_socket_unset_inherit(apr_socket_t *socket)
  + * @tip Same effect as passing the APR_NO_INHERIT flag to apr_socket_create(),
  + * but it is far more efficient to pass the correct value in the first place.
  + */
  +APR_DECLARE_UNSET_INHERIT(socket);
   
   #ifdef __cplusplus
   }
  
  
  
  1.78      +14 -9     apr/network_io/unix/sockets.c
  
  Index: sockets.c
  ===================================================================
  RCS file: /home/cvs/apr/network_io/unix/sockets.c,v
  retrieving revision 1.77
  retrieving revision 1.78
  diff -u -r1.77 -r1.78
  --- sockets.c	2001/07/16 16:11:04	1.77
  +++ sockets.c	2001/07/16 18:14:23	1.78
  @@ -160,9 +160,10 @@
       set_socket_vars(*new, family, type);
   
       (*new)->timeout = -1;
  -    (*new)->inherit = inherit;
  -    apr_pool_cleanup_register((*new)->cntxt, (void *)(*new), 
  -                        socket_cleanup, inherit ? socket_cleanup : NULL );
  +    (*new)->inherit = (inherit & APR_INHERIT) ? 1 : 0;
  +    apr_pool_cleanup_register((*new)->cntxt, (void *)(*new), socket_cleanup,
  +                              (*new)->inherit ? apr_pool_cleanup_null
  +                                              : socket_cleanup);
       return APR_SUCCESS;
   } 
   
  @@ -254,8 +255,9 @@
       }
   
       (*new)->inherit = sock->inherit;
  -    apr_pool_cleanup_register((*new)->cntxt, (void *)(*new), 
  -                        socket_cleanup, (*new)->inherit ? socket_cleanup : NULL);
  +    apr_pool_cleanup_register((*new)->cntxt, (void *)(*new), socket_cleanup,
  +                              (inherit & APR_INHERIT) ? apr_pool_cleanup_null
  +                                                      : socket_cleanup);
       return APR_SUCCESS;
   }
   
  @@ -356,10 +358,11 @@
                  (*apr_sock)->remote_addr->salen);
       }
           
  -    (*apr_sock)->inherit = inherit;
  +    (*apr_sock)->inherit = (inherit & APR_INHERIT) ? 1 : 0;
       apr_pool_cleanup_register((*apr_sock)->cntxt, (void *)(*apr_sock), 
  -                        socket_cleanup, inherit ? socket_cleanup : NULL);
  -
  +                              socket_cleanup,
  +                              (*apr_sock)->inherit ? apr_pool_cleanup_null
  +                                                   : socket_cleanup);
       return APR_SUCCESS;
   }
   
  @@ -378,5 +381,7 @@
       (*sock)->socketdes = *thesock;
       return APR_SUCCESS;
   }
  +
  +APR_IMPLEMENT_SET_INHERIT(socket, cntxt, socket_cleanup)
   
  -APR_SET_INHERIT(socket, cntxt, socket_cleanup, 1)
  +APR_IMPLEMENT_UNSET_INHERIT(socket, cntxt, socket_cleanup)
  
  
  
  1.61      +5 -1      apr/network_io/win32/sockets.c
  
  Index: sockets.c
  ===================================================================
  RCS file: /home/cvs/apr/network_io/win32/sockets.c,v
  retrieving revision 1.60
  retrieving revision 1.61
  diff -u -r1.60 -r1.61
  --- sockets.c	2001/07/12 23:27:50	1.60
  +++ sockets.c	2001/07/16 18:14:24	1.61
  @@ -118,8 +118,10 @@
   }
   
   APR_DECLARE(apr_status_t) apr_socket_create(apr_socket_t **new, int ofamily,
  -                                            int type, apr_pool_t *cont)
  +                                            int type, apr_int32_t inherit,
  +                                            apr_pool_t *cont)
   {
  +    /* XXX: Todo: process the inherit value */
       int family = ofamily;
   
       if (family == AF_UNSPEC) {
  @@ -365,8 +367,10 @@
   
   APR_DECLARE(apr_status_t) apr_os_sock_make(apr_socket_t **apr_sock,
                                              apr_os_sock_info_t *os_sock_info,
  +                                           apr_int32_t inherit,
                                              apr_pool_t *cont)
   {
  +    /* XXX: Todo: process the inherit value */
       alloc_socket(apr_sock, cont);
       set_socket_vars(*apr_sock, os_sock_info->family, os_sock_info->type);
       (*apr_sock)->timeout = -1;
  
  
  

Mime
View raw message