Skip to content

Commit

Permalink
Have inherit_set/unset work correctly. Sockets can't do this, so punt.
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@63556 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
wrowe committed Jul 3, 2002
1 parent df54134 commit cc75cfc
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 6 deletions.
41 changes: 37 additions & 4 deletions include/arch/win32/inherit.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
26 changes: 24 additions & 2 deletions network_io/win32/sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,28 @@ APR_DECLARE(apr_status_t) apr_os_sock_put(apr_socket_t **sock,
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);
}

0 comments on commit cc75cfc

Please sign in to comment.