Skip to content

Commit

Permalink
Last for today (compiles clean on Win32, hope the same for the rest of
Browse files Browse the repository at this point in the history
  our builds.)  Clean up inherit_[un]set and simplify win32 discrepancy
  with inherit.h


git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@63481 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
wrowe committed Jun 8, 2002
1 parent b33025d commit ad3d8ab
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 51 deletions.
4 changes: 2 additions & 2 deletions file_io/os2/open.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ APR_DECLARE(apr_status_t) apr_file_open_stdin(apr_file_t **thefile, apr_pool_t *

APR_POOL_IMPLEMENT_ACCESSOR(file);

APR_IMPLEMENT_SET_INHERIT(file, flags, pool, apr_file_cleanup)
APR_IMPLEMENT_INHERIT_SET(file, flags, pool, apr_file_cleanup)

APR_IMPLEMENT_UNSET_INHERIT(file, flags, pool, apr_file_cleanup)
APR_IMPLEMENT_INHERIT_UNSET(file, flags, pool, apr_file_cleanup)

2 changes: 1 addition & 1 deletion file_io/unix/filedup.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ static apr_status_t _file_dup(apr_file_t **new_file,
(*new_file)->ungetchar = old_file->ungetchar;

/* apr_file_dup() clears the inherit attribute, user must call
* apr_file_set_inherit() again on the dupped handle, as necessary.
* apr_file_inherit_set() again on the dupped handle, as necessary.
*/
(*new_file)->flags = old_file->flags & ~APR_INHERIT;

Expand Down
4 changes: 2 additions & 2 deletions file_io/unix/open.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,8 @@ APR_DECLARE(apr_status_t) apr_file_open_stdin(apr_file_t **thefile,
return apr_os_file_put(thefile, &fd, 0, pool);
}

APR_IMPLEMENT_SET_INHERIT(file, flags, pool, apr_unix_file_cleanup)
APR_IMPLEMENT_INHERIT_SET(file, flags, pool, apr_unix_file_cleanup)

APR_IMPLEMENT_UNSET_INHERIT(file, flags, pool, apr_unix_file_cleanup)
APR_IMPLEMENT_INHERIT_UNSET(file, flags, pool, apr_unix_file_cleanup)

APR_POOL_IMPLEMENT_ACCESSOR(file)
11 changes: 4 additions & 7 deletions file_io/win32/open.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
#include <sys/stat.h>
#endif
#include "misc.h"
#include "inherit.h"

#if APR_HAS_UNICODE_FS
apr_status_t utf8_to_unicode_path(apr_wchar_t* retstr, apr_size_t retlen,
Expand Down Expand Up @@ -605,10 +606,6 @@ APR_DECLARE(apr_status_t) apr_file_open_stdin(apr_file_t **thefile, apr_pool_t *

APR_POOL_IMPLEMENT_ACCESSOR(file);

APR_DECLARE_SET_INHERIT(file) {
return;
}

APR_DECLARE_UNSET_INHERIT(file) {
return;
}
APR_IMPLEMENT_INHERIT_SET(file, flags, pool, file_cleanup)

APR_IMPLEMENT_INHERIT_UNSET(file, flags, pool, file_cleanup)
12 changes: 9 additions & 3 deletions include/apr_file_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ extern "C" {
/** @} */

/**
* @defgroup APR_file_set_attributes File Attribute Flags
* @defgroup APR_file_attrs_set File Attribute Flags
* @{
*/

/* flags for apr_file_set_attributes */
/* flags for apr_file_attrs_set */
#define APR_FILE_ATTR_READONLY 0x01 /**< File is read-only */
#define APR_FILE_ATTR_EXECUTABLE 0x02 /**< File is executable */
/** @} */
Expand Down Expand Up @@ -666,12 +666,18 @@ APR_POOL_DECLARE_ACCESSOR(file);
* @param file The file to enable inheritance.
*
*/
APR_DECLARE(void) apr_file_set_inherit(apr_file_t *file);
APR_DECLARE(void) apr_file_inherit_set(apr_file_t *file);

/**
* Unset a file from being inherited by child processes.
* @param file The file to disable inheritance.
*/
APR_DECLARE(void) apr_file_inherit_unset(apr_file_t *file);

/** @deprecated @see apr_file_inherit_set */
APR_DECLARE(void) apr_file_set_inherit(apr_file_t *file);

/** @deprecated @see apr_file_inherit_unset */
APR_DECLARE(void) apr_file_unset_inherit(apr_file_t *file);

/**
Expand Down
11 changes: 6 additions & 5 deletions include/apr_inherit.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,18 @@
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

/**
* @param name Set Inheritance for this Socket/File Handle
*/
#define APR_DECLARE_SET_INHERIT(name) \
APR_DECLARE(void) apr_##name##_set_inherit(apr_##name##_t *name)
#define APR_DECLARE_INHERIT_SET(name) \
APR_DECLARE(void) apr_##name##_inherit_set(apr_##name##_t *name)

/**
* @param name Unset Inheritance for this Socket/File Handle
*/

#define APR_DECLARE_UNSET_INHERIT(name) \
APR_DECLARE(void) apr_##name##_unset_inherit(apr_##name##_t *name)
#define APR_DECLARE_INHERIT_UNSET(name) \
APR_DECLARE(void) apr_##name##_inherit_unset(apr_##name##_t *name)

#ifdef __cplusplus
}
Expand Down
8 changes: 7 additions & 1 deletion include/apr_network_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -811,13 +811,19 @@ apr_status_t apr_socket_accept_filter(apr_socket_t *sock, char *name,
* Set a socket to be inherited by child processes.
* @param socket The socket to enable inheritance.
*/
APR_DECLARE(void) apr_socket_inherit_set(apr_socket_t *skt);

/** @deprecated @see apr_socket_inherit_set */
APR_DECLARE(void) apr_socket_set_inherit(apr_socket_t *skt);

/**
* Unset a socket from being inherited by child processes.
* @param socket The socket to disable inheritance.
*/
APR_DECLARE(void) apr_socket_unset_inherit(apr_socket_t *skt);
APR_DECLARE(void) apr_socket_inherit_unset(apr_socket_t *skt);

/** @deprecated @see apr_socket_inherit_set */
APR_DECLARE(void) apr_socket_set_inherit(apr_socket_t *skt);

#ifdef __cplusplus
}
Expand Down
18 changes: 14 additions & 4 deletions include/arch/unix/inherit.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,24 +59,34 @@

#define APR_INHERIT (2^24) /* Must not conflicts with other bits */

#define APR_IMPLEMENT_SET_INHERIT(name, flag, pool, cleanup) \
void apr_##name##_set_inherit(apr_##name##_t *name) \
#define APR_IMPLEMENT_INHERIT_SET(name, flag, pool, cleanup) \
void apr_##name##_inherit_set(apr_##name##_t *name) \
{ \
if (!(name->flag & APR_INHERIT)) { \
name->flag |= APR_INHERIT; \
apr_pool_child_cleanup_set(name->pool, (void *)name, \
cleanup, apr_pool_cleanup_null); \
} \
} \
/* Deprecated */ \
void apr_##name##_set_inherit(apr_##name##_t *name) \
{ \
apr_##name##_inherit_set(name); \
}

#define APR_IMPLEMENT_UNSET_INHERIT(name, flag, pool, cleanup) \
void apr_##name##_unset_inherit(apr_##name##_t *name) \
#define APR_IMPLEMENT_INHERIT_UNSET(name, flag, pool, cleanup) \
void apr_##name##_inherit_unset(apr_##name##_t *name) \
{ \
if (name->flag & APR_INHERIT) { \
name->flag &= ~APR_INHERIT; \
apr_pool_child_cleanup_set(name->pool, (void *)name, \
cleanup, cleanup); \
} \
} \
/* Deprecated */ \
void apr_##name##_unset_inherit(apr_##name##_t *name) \
{ \
apr_##name##_inherit_unset(name); \
}

#endif /* ! INHERIT_H */
24 changes: 8 additions & 16 deletions include/arch/win32/inherit.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,33 +60,25 @@
#define APR_INHERIT (2^24) /* Must not conflicts with other bits */

#define APR_IMPLEMENT_INHERIT_SET(name, flag, pool, cleanup) \
void apr_##name##_inherit_set(apr_##name##_t *name) \
APR_DECLARE(void) apr_##name##_inherit_set(apr_##name##_t *name) \
{ \
if (!(name->flag & APR_INHERIT)) { \
name->flag |= APR_INHERIT; \
apr_pool_child_cleanup_set(name->pool, (void *)name, \
cleanup, apr_pool_cleanup_null); \
} \
return; \
} \
/* Deprecated */ \
void apr_##name##_set_inherit(apr_##name##_t *name) \
APR_DECLARE(void) apr_##name##_set_inherit(apr_##name##_t *name) \
{ \
apr_##name##_inherit_set(apr_##name##_t *name) \
apr_##name##_inherit_set(name); \
}

#define APR_IMPLEMENT_INHERIT_UNSET(name, flag, pool, cleanup) \
void apr_##name##_inherit_unset(apr_##name##_t *name) \
APR_DECLARE(void) apr_##name##_inherit_unset(apr_##name##_t *name) \
{ \
if (name->flag & APR_INHERIT) { \
name->flag &= ~APR_INHERIT; \
apr_pool_child_cleanup_set(name->pool, (void *)name, \
cleanup, cleanup); \
} \
return; \
} \
/* Deprecated */ \
void apr_##name##_unset_inherit(apr_##name##_t *name) \
APR_DECLARE(void) apr_##name##_unset_inherit(apr_##name##_t *name) \
{ \
apr_##name##_inherit_unset(apr_##name##_t *name) \
apr_##name##_inherit_unset(name); \
}

#endif /* ! INHERIT_H */
4 changes: 2 additions & 2 deletions network_io/os2/sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,6 @@ APR_DECLARE(apr_status_t) apr_os_sock_put(apr_socket_t **sock, apr_os_sock_t *th
return APR_SUCCESS;
}

APR_IMPLEMENT_SET_INHERIT(socket, inherit, cntxt, socket_cleanup)
APR_IMPLEMENT_INHERIT_SET(socket, inherit, cntxt, socket_cleanup)

APR_IMPLEMENT_UNSET_INHERIT(socket, inherit, cntxt, socket_cleanup)
APR_IMPLEMENT_INHERIT_UNSET(socket, inherit, cntxt, socket_cleanup)
4 changes: 2 additions & 2 deletions network_io/unix/sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,6 @@ apr_status_t apr_os_sock_put(apr_socket_t **sock, apr_os_sock_t *thesock,
return APR_SUCCESS;
}

APR_IMPLEMENT_SET_INHERIT(socket, inherit, cntxt, socket_cleanup)
APR_IMPLEMENT_INHERIT_SET(socket, inherit, cntxt, socket_cleanup)

APR_IMPLEMENT_UNSET_INHERIT(socket, inherit, cntxt, socket_cleanup)
APR_IMPLEMENT_INHERIT_UNSET(socket, inherit, cntxt, socket_cleanup)
9 changes: 3 additions & 6 deletions network_io/win32/sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
#include "apr_lib.h"
#include "apr_portable.h"
#include <string.h>
#include "inherit.h"

static char generic_inaddr_any[16] = {0}; /* big enough for IPv4 or IPv6 */

Expand Down Expand Up @@ -423,10 +424,6 @@ APR_DECLARE(apr_status_t) apr_os_sock_put(apr_socket_t **sock,
return APR_SUCCESS;
}

APR_DECLARE_SET_INHERIT(socket) {
return;
}
APR_IMPLEMENT_INHERIT_SET(socket, inherit, cntxt, socket_cleanup)

APR_DECLARE_UNSET_INHERIT(socket) {
return;
}
APR_IMPLEMENT_INHERIT_UNSET(socket, inherit, cntxt, socket_cleanup)

0 comments on commit ad3d8ab

Please sign in to comment.