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 Wed, 03 Jul 2002 00:16:55 GMT
wrowe       2002/07/02 17:16:55

  Modified:    include/arch/win32 inherit.h
               network_io/win32 sockets.c
  Log:
    Have inherit_set/unset work correctly.  Sockets can't do this, so punt.
  
  Revision  Changes    Path
  1.3       +37 -4     apr/include/arch/win32/inherit.h
  
  Index: inherit.h
  ===================================================================
  RCS file: /home/cvs/apr/include/arch/win32/inherit.h,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- inherit.h	8 Jun 2002 22:32:11 -0000	1.2
  +++ inherit.h	3 Jul 2002 00:16:55 -0000	1.3
  @@ -62,23 +62,56 @@
   #define APR_IMPLEMENT_INHERIT_SET(name, flag, pool, cleanup)        \
   APR_DECLARE(void) apr_##name##_inherit_set(apr_##name##_t *name)    \
   {                                                                   \
  -    return;                                                         \
  +    IF_WIN_OS_IS_UNICODE                                            \
  +    {                                                               \
  +        if (!SetHandleInformation(name->filehand,                   \
  +                                  HANDLE_FLAG_INHERIT,              \
  +                                  HANDLE_FLAG_INHERIT))             \
  +            return /* apr_get_os_error() */;                        \
  +    }                                                               \
  +    ELSE_WIN_OS_IS_ANSI                                             \
  +    {                                                               \
  +        HANDLE temp, hproc = GetCurrentProcess();                   \
  +        if (!DuplicateHandle(hproc, name->filehand,                 \
  +                             hproc, &temp, 0, TRUE,                 \
  +                             DUPLICATE_SAME_ACCESS))                \
  +            return /* apr_get_os_error() */;                        \
  +        CloseHandle(name->filehand);                                \
  +        name->filehand = temp;                                      \
  +    }                                                               \
  +    return /* APR_SUCCESS */;                                       \
   }                                                                   \
   /* Deprecated */                                                    \
   APR_DECLARE(void) apr_##name##_set_inherit(apr_##name##_t *name)    \
   {                                                                   \
  -    apr_##name##_inherit_set(name);                                 \
  +    /* return */ apr_##name##_inherit_set(name);                    \
   }
   
   #define APR_IMPLEMENT_INHERIT_UNSET(name, flag, pool, cleanup)      \
   APR_DECLARE(void) apr_##name##_inherit_unset(apr_##name##_t *name)  \
   {                                                                   \
  -    return;                                                         \
  +    IF_WIN_OS_IS_UNICODE                                            \
  +    {                                                               \
  +        if (!SetHandleInformation(name->filehand,                   \
  +                                  HANDLE_FLAG_INHERIT, 0))          \
  +            return /* apr_get_os_error() */;                        \
  +    }                                                               \
  +    ELSE_WIN_OS_IS_ANSI                                             \
  +    {                                                               \
  +        HANDLE temp, hproc = GetCurrentProcess();                   \
  +        if (!DuplicateHandle(hproc, name->filehand,                 \
  +                             hproc, &temp, 0, FALSE,                \
  +                             DUPLICATE_SAME_ACCESS))                \
  +            return /* apr_get_os_error() */;                        \
  +        CloseHandle(name->filehand);                                \
  +        name->filehand = temp;                                      \
  +    }                                                               \
  +    return /* APR_SUCCESS */;                                       \
   }                                                                   \
   /* Deprecated */                                                    \
   APR_DECLARE(void) apr_##name##_unset_inherit(apr_##name##_t *name)  \
   {                                                                   \
  -    apr_##name##_inherit_unset(name);                               \
  +    /* return */ apr_##name##_inherit_unset(name);                  \
   }
   
   #endif	/* ! INHERIT_H */
  
  
  
  1.79      +24 -2     apr/network_io/win32/sockets.c
  
  Index: sockets.c
  ===================================================================
  RCS file: /home/cvs/apr/network_io/win32/sockets.c,v
  retrieving revision 1.78
  retrieving revision 1.79
  diff -u -r1.78 -r1.79
  --- sockets.c	8 Jun 2002 22:32:11 -0000	1.78
  +++ sockets.c	3 Jul 2002 00:16:55 -0000	1.79
  @@ -424,6 +424,28 @@
       return APR_SUCCESS;
   }
   
  -APR_IMPLEMENT_INHERIT_SET(socket, inherit, cntxt, socket_cleanup)
   
  -APR_IMPLEMENT_INHERIT_UNSET(socket, inherit, cntxt, socket_cleanup)
  +/* Sockets cannot be inherited through the standard sockets
  + * inheritence.  WSADuplicateSocket must be used.
  + * This is not trivial to implement.
  + */
  +
  +APR_DECLARE(void) apr_socket_inherit_set(apr_socket_t *socket)    
  +{    
  +    return /* APR_ENOTIMPL */;
  +}    
  +/* Deprecated */    
  +APR_DECLARE(void) apr_socket_set_inherit(apr_socket_t *socket)    
  +{    
  +    /* return */ apr_socket_inherit_set(socket);    
  +}
  +
  +APR_DECLARE(void) apr_socket_inherit_unset(apr_socket_t *socket)    
  +{    
  +    return /* APR_ENOTIMPL */;
  +}    
  +/* Deprecated */    
  +APR_DECLARE(void) apr_socket_unset_inherit(apr_socket_t *socket)    
  +{    
  +    /* return */ apr_socket_inherit_unset(socket);    
  +}
  
  
  

Mime
View raw message