diff options
author | Ryan Bloom <rbb@apache.org> | 1999-08-31 05:32:53 +0000 |
---|---|---|
committer | Ryan Bloom <rbb@apache.org> | 1999-08-31 05:32:53 +0000 |
commit | d8bb029e1606cec52af7ed92e37e0af4ce03e364 (patch) | |
tree | b0538e9e29dff02e4e52005cc29b8007cdf9748c | |
parent | a51b4dac38899a3c43f003f1bc2de7136f811409 (diff) | |
download | apr-d8bb029e1606cec52af7ed92e37e0af4ce03e364.tar.gz |
Changed pools to contexts. Tested with prefork and pthread mpm's. I'll
check this out tomorrow and make sure everything was checked in correctly.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@59183 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | inc/apr_fnmatch.h | 4 | ||||
-rw-r--r-- | inc/apr_pools.h | 74 | ||||
-rw-r--r-- | include/apr_fnmatch.h | 4 | ||||
-rw-r--r-- | include/apr_lib.h | 65 | ||||
-rw-r--r-- | include/apr_md5.h | 10 | ||||
-rw-r--r-- | include/apr_pools.h | 74 | ||||
-rw-r--r-- | include/arch/unix/threadproc.h | 2 | ||||
-rw-r--r-- | lib/apr_cpystrn.c | 4 | ||||
-rw-r--r-- | lib/apr_execve.c | 16 | ||||
-rw-r--r-- | lib/apr_fnmatch.c | 14 | ||||
-rw-r--r-- | lib/apr_getpass.c | 4 | ||||
-rw-r--r-- | lib/apr_md5.c | 74 | ||||
-rw-r--r-- | lib/apr_pools.c | 167 | ||||
-rw-r--r-- | lib/apr_signal.c | 2 | ||||
-rw-r--r-- | lib/apr_slack.c | 8 | ||||
-rw-r--r-- | lib/apr_tables.c | 30 | ||||
-rw-r--r-- | locks/unix/crossproc.c | 4 | ||||
-rw-r--r-- | memory/unix/apr_pools.c | 167 | ||||
-rw-r--r-- | misc/beos/start.c | 6 | ||||
-rw-r--r-- | misc/os2/start.c | 6 | ||||
-rw-r--r-- | misc/unix/start.c | 2 | ||||
-rw-r--r-- | misc/win32/start.c | 6 | ||||
-rw-r--r-- | shmem/shmem.c | 2 | ||||
-rw-r--r-- | shmem/unix/mm/mm_alloc.c | 6 | ||||
-rw-r--r-- | shmem/unix/shmem.c | 2 | ||||
-rw-r--r-- | test/ab_apr.c | 8 | ||||
-rw-r--r-- | test/htdigest.c | 6 | ||||
-rw-r--r-- | test/logresolve.c | 2 | ||||
-rw-r--r-- | test/testfile.c | 5 | ||||
-rw-r--r-- | threadproc/unix/proc.c | 2 | ||||
-rw-r--r-- | threadproc/unix/threadproc.h | 2 |
31 files changed, 451 insertions, 327 deletions
diff --git a/inc/apr_fnmatch.h b/inc/apr_fnmatch.h index ba194c303..1b28b1923 100644 --- a/inc/apr_fnmatch.h +++ b/inc/apr_fnmatch.h @@ -53,9 +53,9 @@ extern "C" { #define FNM_PATHNAME 0x02 /* Slash must be matched by slash. */ #define FNM_PERIOD 0x04 /* Period must be matched by period. */ /* This flag is an Apache addition */ -#define FNM_CASE_BLIND 0x08 /* Compare characters case-insensitively. */ +#define FNM_CASE_BLIND 0x08 /* Compare characters case ap_context_t nsensitively. */ -API_EXPORT(int) apr_fnmatch(const char *pattern, const char *strings, +API_EXPORT(int) ap_fnmatch(const char *pattern, const char *strings, int flags); /* this function is an Apache addition */ diff --git a/inc/apr_pools.h b/inc/apr_pools.h index 5c97c6f44..adfb031e5 100644 --- a/inc/apr_pools.h +++ b/inc/apr_pools.h @@ -72,14 +72,14 @@ extern "C" { * Instead, we maintain pools, and allocate items (both memory and I/O * handlers) from the pools --- currently there are two, one for per * transaction info, and one for config info. When a transaction is over, - * we can delete everything in the per-transaction pool without fear, and + * we can delete everything in the per-transaction ap_context_t without fear, and * without thinking too hard about it either. * * rst */ /* Arenas for configuration info and transaction info - * --- actual layout of the pool structure is private to + * --- actual layout of the ap_context_t structure is private to * alloc.c. */ @@ -168,7 +168,7 @@ API_EXPORT_NONSTD(char *) ap_psprintf(struct context_t *, const char *fmt, ...) * Common enough to want common support code ... */ -/* ap_array_pstrcat generates a new string from the pool containing +/* ap_array_pstrcat generates a new string from the ap_context_t containing * the concatenated sequence of substrings referenced as elements within * the array. The string will be empty if all substrings are empty or null, * or if there are no elements in the array. @@ -207,10 +207,39 @@ API_EXPORT_NONSTD(char *) ap_psprintf(struct context_t *, const char *fmt, ...) #define ap_OVERLAP_TABLES_SET (0) #define ap_OVERLAP_TABLES_MERGE (1) -/* XXX: these know about the definition of struct table in alloc.c. That +/* A set of flags which indicate places where the server should raise(SIGSTOP). + * This is useful for debugging, because you can then attach to that process + * with gdb and continue. This is important in cases where one_process + * debugging isn't possible. + */ +#define SIGSTOP_DETACH 1 +#define SIGSTOP_MAKE_CHILD 2 #define SIGSTOP_SPAWN_CHILD 4 +#define SIGSTOP_PIPED_LOG_SPAWN 8 +#define SIGSTOP_CGI_CHILD 16 + +#ifdef DEBUG_SIGSTOP +extern int raise_sigstop_flags; +#define RAISE_SIGSTOP(x) do { \ + if (raise_sigstop_flags & SIGSTOP_##x) raise(SIGSTOP);\ + } while (0) +#else +#define RAISE_SIGSTOP(x) +#endif + +#ifdef ULTRIX_BRAIN_DEATH +#define ap_fdopen(d,m) fdopen((d), (char *)(m)) +#else +#define ap_fdopen(d,m) fdopen((d), (m)) +#endif + +#define closesocket(s) close(s) + + + +/* XXX: these know about the definition of struct ap_table_t in alloc.c. That * definition is not here because it is supposed to be private, and by not * placing it here we are able to get compile-time diagnostics from modules - * written which assume that a table is the same as an ap_array_header_t. -djg + * written which assume that a ap_table_t is the same as an ap_array_header_t. -djg */ #define ap_table_elts(t) ((ap_array_header_t *)(t)) #define ap_is_empty_table(t) (((t) == NULL)||(((ap_array_header_t *)(t))->nelts == 0)) @@ -254,31 +283,28 @@ API_EXPORT_NONSTD(char *) ap_psprintf(struct context_t *, const char *fmt, ...) * the note_cleanups_for_foo routines are for */ -API_EXPORT(FILE *) ap_pfopen(ap_pool_t *, const char *name, const char *fmode); -API_EXPORT(FILE *) ap_pfdopen(ap_pool_t *, int fd, const char *fmode); -API_EXPORT(int) ap_popenf(ap_pool_t *, const char *name, int flg, int mode); - -API_EXPORT(void) ap_note_cleanups_for_file(ap_pool_t *, FILE *); -API_EXPORT(void) ap_note_cleanups_for_fd(ap_pool_t *, int); -API_EXPORT(void) ap_kill_cleanups_for_fd(ap_pool_t *p, int fd); -API_EXPORT(void) ap_note_cleanups_for_socket(ap_pool_t *, int); -API_EXPORT(void) ap_kill_cleanups_for_socket(ap_pool_t *p, int sock); -API_EXPORT(int) ap_psocket(ap_pool_t *p, int, int, int); -API_EXPORT(int) ap_pclosesocket(ap_pool_t *a, int sock); -API_EXPORT(regex_t *) ap_pregcomp(ap_pool_t *p, const char *pattern, - int cflags); -API_EXPORT(void) ap_pregfree(ap_pool_t *p, regex_t * reg); +API_EXPORT(FILE *) ap_pfopen(ap_context_t *, const char *name, const char *fmode); +API_EXPORT(FILE *) ap_pfdopen(ap_context_t *, int fd, const char *fmode); +API_EXPORT(int) ap_popenf(ap_context_t *, const char *name, int flg, int mode); + +API_EXPORT(void) ap_note_cleanups_for_file(ap_context_t *, FILE *); +API_EXPORT(void) ap_note_cleanups_for_fd(ap_context_t *, int); +API_EXPORT(void) ap_kill_cleanups_for_fd(ap_context_t *p, int fd); +API_EXPORT(void) ap_note_cleanups_for_socket(ap_context_t *, int); +API_EXPORT(void) ap_kill_cleanups_for_socket(ap_context_t *p, int sock); +API_EXPORT(int) ap_psocket(ap_context_t *p, int, int, int); +API_EXPORT(int) ap_pclosesocket(ap_context_t *a, int sock); /* routines to note closes... file descriptors are constrained enough * on some systems that we want to support this. */ -API_EXPORT(int) ap_pfclose(ap_pool_t *, FILE *); -API_EXPORT(int) ap_pclosef(ap_pool_t *, int fd); +API_EXPORT(int) ap_pfclose(ap_context_t *, FILE *); +API_EXPORT(int) ap_pclosef(ap_context_t *, int fd); /* routines to deal with directories */ -/*API_EXPORT(DIR *) ap_popendir(ap_pool_t *p, const char *name); -API_EXPORT(void) ap_pclosedir(ap_pool_t *p, DIR * d); +/*API_EXPORT(DIR *) ap_popendir(ap_context_t *p, const char *name); +API_EXPORT(void) ap_pclosedir(ap_context_t *p, DIR * d); */ /* ... even child processes (which we may want to wait for, * or to kill outright, on unexpected termination). @@ -293,7 +319,7 @@ API_EXPORT(void) ap_pclosedir(ap_pool_t *p, DIR * d); API_EXPORT(void) ap_note_subprocess(struct context_t *a, pid_t pid, enum kill_conditions how); -/* magic numbers --- min free bytes to consider a free pool block useable, +/* magic numbers --- min free bytes to consider a free ap_context_t block useable, * and the min amount to allocate if we have to go to malloc() */ #ifndef BLOCK_MINFREE diff --git a/include/apr_fnmatch.h b/include/apr_fnmatch.h index ba194c303..1b28b1923 100644 --- a/include/apr_fnmatch.h +++ b/include/apr_fnmatch.h @@ -53,9 +53,9 @@ extern "C" { #define FNM_PATHNAME 0x02 /* Slash must be matched by slash. */ #define FNM_PERIOD 0x04 /* Period must be matched by period. */ /* This flag is an Apache addition */ -#define FNM_CASE_BLIND 0x08 /* Compare characters case-insensitively. */ +#define FNM_CASE_BLIND 0x08 /* Compare characters case ap_context_t nsensitively. */ -API_EXPORT(int) apr_fnmatch(const char *pattern, const char *strings, +API_EXPORT(int) ap_fnmatch(const char *pattern, const char *strings, int flags); /* this function is an Apache addition */ diff --git a/include/apr_lib.h b/include/apr_lib.h index 02294c4a5..1988ddc79 100644 --- a/include/apr_lib.h +++ b/include/apr_lib.h @@ -66,6 +66,7 @@ #include "apr_general.h" #include "apr_file_io.h" +#include <dirent.h> #ifndef WIN32 #include "apr_config.h" #else @@ -132,10 +133,10 @@ typedef struct ap_table_entry_t { char *val; } ap_table_entry_t; -/* XXX: these know about the definition of struct table in alloc.c. That +/* XXX: these know about the definition of struct ap_table_t in alloc.c. That * definition is not here because it is supposed to be private, and by not * placing it here we are able to get compile-time diagnostics from modules - * written which assume that a table is the same as an ap_array_header_t. -djg + * written which assume that a ap_table_t is the same as an ap_array_header_t. -djg */ #define ap_table_elts(t) ((ap_array_header_t *)(t)) #define ap_is_empty_table(t) (((t) == NULL)||(((ap_array_header_t *)(t))->nelts == 0)) @@ -150,7 +151,7 @@ typedef struct ap_vformatter_buff_t { enum kill_conditions { kill_never, /* process is never sent any signals */ - kill_always, /* process is sent SIGKILL on pool cleanup */ + kill_always, /* process is sent SIGKILL on ap_context_t cleanup */ kill_after_timeout, /* SIGTERM, wait 3 seconds, SIGKILL */ just_wait, /* wait forever for the process to complete */ kill_only_once /* send SIGTERM and then wait */ @@ -237,7 +238,7 @@ API_EXPORT_NONSTD(int) ap_execve(const char *c, const char *argv[], * can return -1 to indicate that no further output should be attempted, * and ap_vformatter will return immediately with -1. Otherwise * the flush_func should flush the buffer in whatever manner is - * appropriate, re-initialize curpos and endpos, and return 0. + * appropriate, re ap_context_t nitialize curpos and endpos, and return 0. * * Note that flush_func is only invoked as a result of attempting to * write another byte at curpos when curpos >= endpos. So for @@ -293,6 +294,18 @@ API_EXPORT(long) ap_bytes_in_free_blocks(void); API_EXPORT(ap_pool_t *) ap_find_pool(const void *ts); API_EXPORT(int) ap_pool_is_ancestor(ap_pool_t *a, ap_pool_t *b); API_EXPORT(void) ap_pool_join(ap_pool_t *p, ap_pool_t *sub); + +/* used to guarantee to the ap_context_t debugging code that the sub ap_context_t will not be + * destroyed before the parent pool + */ +#ifndef POOL_DEBUG +#ifdef ap_pool_join +#undef ap_pool_join +#endif /* ap_pool_join */ +#define ap_pool_join(a,b) +#endif /* POOL_DEBUG */ + + API_EXPORT(void *) ap_palloc(struct context_t *c, int reqsize); API_EXPORT(void *) ap_pcalloc(struct context_t *p, int size); API_EXPORT(char *) ap_pstrdup(struct context_t *p, const char *s); @@ -353,45 +366,45 @@ API_EXPORT(void) ap_run_cleanup(struct context_t *p, void *data, ap_status_t (*cleanup) (void *)); API_EXPORT(void) ap_cleanup_for_exec(void); API_EXPORT(ap_status_t) ap_getpass(const char *prompt, char *pwbuf, size_t *bufsize); -API_EXPORT_NONSTD(void) ap_null_cleanup(void *data); -/* -API_EXPORT(void) ap_note_cleanups_for_fd(ap_pool_t *p, int fd); -API_EXPORT(void) ap_kill_cleanups_for_fd(ap_pool_t *p, int fd); -API_EXPORT(int) ap_popenf(ap_pool_t *a, const char *name, int flg, int mode); -API_EXPORT(int) ap_pclosef(ap_pool_t *a, int fd); -API_EXPORT(void) ap_note_cleanups_for_file(ap_pool_t *p, FILE *fp); -API_EXPORT(FILE *) ap_pfopen(ap_pool_t *a, const char *name, +API_EXPORT_NONSTD(ap_status_t) ap_null_cleanup(void *data); + +API_EXPORT(void) ap_note_cleanups_for_fd(ap_context_t *p, int fd); +API_EXPORT(void) ap_kill_cleanups_for_fd(ap_context_t *p, int fd); +API_EXPORT(int) ap_popenf(ap_context_t *a, const char *name, int flg, int mode); +API_EXPORT(int) ap_pclosef(ap_context_t *a, int fd); +API_EXPORT(void) ap_note_cleanups_for_file(ap_context_t *p, FILE *fp); +API_EXPORT(FILE *) ap_pfopen(ap_context_t *a, const char *name, const char *mode); -API_EXPORT(FILE *) ap_pfdopen(ap_pool_t *a, int fd, const char *mode); -API_EXPORT(int) ap_pfclose(ap_pool_t *a, FILE *fd); -API_EXPORT(DIR *) ap_popendir(ap_pool_t *p, const char *name); -API_EXPORT(void) ap_pclosedir(ap_pool_t *p, DIR * d); -API_EXPORT(void) ap_note_cleanups_for_socket(ap_pool_t *p, int fd); -API_EXPORT(void) ap_kill_cleanups_for_socket(ap_pool_t *p, int sock); -API_EXPORT(int) ap_psocket(ap_pool_t *p, int domain, int type, int protocol); -API_EXPORT(int) ap_pclosesocket(ap_pool_t *a, int sock); -*/ -API_EXPORT(regex_t *) ap_pregcomp(ap_pool_t *p, const char *pattern, +API_EXPORT(FILE *) ap_pfdopen(ap_context_t *a, int fd, const char *mode); +API_EXPORT(int) ap_pfclose(ap_context_t *a, FILE *fd); +API_EXPORT(DIR *) ap_popendir(ap_context_t *p, const char *name); +API_EXPORT(void) ap_pclosedir(ap_context_t *p, DIR * d); +API_EXPORT(void) ap_note_cleanups_for_socket(ap_context_t *p, int fd); +API_EXPORT(void) ap_kill_cleanups_for_socket(ap_context_t *p, int sock); +API_EXPORT(int) ap_psocket(ap_context_t *p, int domain, int type, int protocol); +API_EXPORT(int) ap_pclosesocket(ap_context_t *a, int sock); + +API_EXPORT(regex_t *) ap_pregcomp(ap_context_t *p, const char *pattern, int cflags); -API_EXPORT(void) ap_pregfree(ap_pool_t *p, regex_t *reg); +API_EXPORT(void) ap_pregfree(ap_context_t *p, regex_t *reg); /*API_EXPORT(void) ap_note_subprocess(ap_pool_t *a, pid_t pid, enum kill_conditions how); */ API_EXPORT(int) - ap_spawn_child(ap_pool_t *p, + ap_spawn_child(ap_context_t *p, int (*func) (void *a, ap_child_info_t *c), void *data, enum kill_conditions kill_how, FILE **pipe_in, FILE **pipe_out, FILE **pipe_err); #if 0 API_EXPORT(int) - ap_bspawn_child(ap_pool_t *p, + ap_bspawn_child(ap_context_t *p, int (*func) (void *v, ap_child_info_t *c), void *data, enum kill_conditions kill_how, BUFF **pipe_in, BUFF **pipe_out, BUFF **pipe_err); #endif /* 0 */ -API_EXPORT(char *) apr_cpystrn(char *dst, const char *src, size_t dst_size); +API_EXPORT(char *) ap_cpystrn(char *dst, const char *src, size_t dst_size); /* * Routine definitions that only work on Windows. diff --git a/include/apr_md5.h b/include/apr_md5.h index 53d8f5c04..55ac978d5 100644 --- a/include/apr_md5.h +++ b/include/apr_md5.h @@ -113,13 +113,13 @@ typedef struct { unsigned char buffer[64]; /* input buffer */ } APR_MD5_CTX; -API_EXPORT(void) apr_MD5Init(APR_MD5_CTX * context); -API_EXPORT(void) apr_MD5Update(APR_MD5_CTX * context, const unsigned char *input, +API_EXPORT(void) ap_MD5Init(APR_MD5_CTX * context); +API_EXPORT(void) ap_MD5Update(APR_MD5_CTX * context, const unsigned char *input, unsigned int inputLen); -API_EXPORT(void) apr_MD5Final(unsigned char digest[16], APR_MD5_CTX * context); -API_EXPORT(void) apr_MD5Encode(const char *password, const char *salt, +API_EXPORT(void) ap_MD5Final(unsigned char digest[16], APR_MD5_CTX * context); +API_EXPORT(void) ap_MD5Encode(const char *password, const char *salt, char *result, size_t nbytes); -API_EXPORT(char *) apr_validate_password(const char *passwd, const char *hash); +API_EXPORT(char *) ap_validate_password(const char *passwd, const char *hash); #ifdef __cplusplus } diff --git a/include/apr_pools.h b/include/apr_pools.h index 5c97c6f44..adfb031e5 100644 --- a/include/apr_pools.h +++ b/include/apr_pools.h @@ -72,14 +72,14 @@ extern "C" { * Instead, we maintain pools, and allocate items (both memory and I/O * handlers) from the pools --- currently there are two, one for per * transaction info, and one for config info. When a transaction is over, - * we can delete everything in the per-transaction pool without fear, and + * we can delete everything in the per-transaction ap_context_t without fear, and * without thinking too hard about it either. * * rst */ /* Arenas for configuration info and transaction info - * --- actual layout of the pool structure is private to + * --- actual layout of the ap_context_t structure is private to * alloc.c. */ @@ -168,7 +168,7 @@ API_EXPORT_NONSTD(char *) ap_psprintf(struct context_t *, const char *fmt, ...) * Common enough to want common support code ... */ -/* ap_array_pstrcat generates a new string from the pool containing +/* ap_array_pstrcat generates a new string from the ap_context_t containing * the concatenated sequence of substrings referenced as elements within * the array. The string will be empty if all substrings are empty or null, * or if there are no elements in the array. @@ -207,10 +207,39 @@ API_EXPORT_NONSTD(char *) ap_psprintf(struct context_t *, const char *fmt, ...) #define ap_OVERLAP_TABLES_SET (0) #define ap_OVERLAP_TABLES_MERGE (1) -/* XXX: these know about the definition of struct table in alloc.c. That +/* A set of flags which indicate places where the server should raise(SIGSTOP). + * This is useful for debugging, because you can then attach to that process + * with gdb and continue. This is important in cases where one_process + * debugging isn't possible. + */ +#define SIGSTOP_DETACH 1 +#define SIGSTOP_MAKE_CHILD 2 #define SIGSTOP_SPAWN_CHILD 4 +#define SIGSTOP_PIPED_LOG_SPAWN 8 +#define SIGSTOP_CGI_CHILD 16 + +#ifdef DEBUG_SIGSTOP +extern int raise_sigstop_flags; +#define RAISE_SIGSTOP(x) do { \ + if (raise_sigstop_flags & SIGSTOP_##x) raise(SIGSTOP);\ + } while (0) +#else +#define RAISE_SIGSTOP(x) +#endif + +#ifdef ULTRIX_BRAIN_DEATH +#define ap_fdopen(d,m) fdopen((d), (char *)(m)) +#else +#define ap_fdopen(d,m) fdopen((d), (m)) +#endif + +#define closesocket(s) close(s) + + + +/* XXX: these know about the definition of struct ap_table_t in alloc.c. That * definition is not here because it is supposed to be private, and by not * placing it here we are able to get compile-time diagnostics from modules - * written which assume that a table is the same as an ap_array_header_t. -djg + * written which assume that a ap_table_t is the same as an ap_array_header_t. -djg */ #define ap_table_elts(t) ((ap_array_header_t *)(t)) #define ap_is_empty_table(t) (((t) == NULL)||(((ap_array_header_t *)(t))->nelts == 0)) @@ -254,31 +283,28 @@ API_EXPORT_NONSTD(char *) ap_psprintf(struct context_t *, const char *fmt, ...) * the note_cleanups_for_foo routines are for */ -API_EXPORT(FILE *) ap_pfopen(ap_pool_t *, const char *name, const char *fmode); -API_EXPORT(FILE *) ap_pfdopen(ap_pool_t *, int fd, const char *fmode); -API_EXPORT(int) ap_popenf(ap_pool_t *, const char *name, int flg, int mode); - -API_EXPORT(void) ap_note_cleanups_for_file(ap_pool_t *, FILE *); -API_EXPORT(void) ap_note_cleanups_for_fd(ap_pool_t *, int); -API_EXPORT(void) ap_kill_cleanups_for_fd(ap_pool_t *p, int fd); -API_EXPORT(void) ap_note_cleanups_for_socket(ap_pool_t *, int); -API_EXPORT(void) ap_kill_cleanups_for_socket(ap_pool_t *p, int sock); -API_EXPORT(int) ap_psocket(ap_pool_t *p, int, int, int); -API_EXPORT(int) ap_pclosesocket(ap_pool_t *a, int sock); -API_EXPORT(regex_t *) ap_pregcomp(ap_pool_t *p, const char *pattern, - int cflags); -API_EXPORT(void) ap_pregfree(ap_pool_t *p, regex_t * reg); +API_EXPORT(FILE *) ap_pfopen(ap_context_t *, const char *name, const char *fmode); +API_EXPORT(FILE *) ap_pfdopen(ap_context_t *, int fd, const char *fmode); +API_EXPORT(int) ap_popenf(ap_context_t *, const char *name, int flg, int mode); + +API_EXPORT(void) ap_note_cleanups_for_file(ap_context_t *, FILE *); +API_EXPORT(void) ap_note_cleanups_for_fd(ap_context_t *, int); +API_EXPORT(void) ap_kill_cleanups_for_fd(ap_context_t *p, int fd); +API_EXPORT(void) ap_note_cleanups_for_socket(ap_context_t *, int); +API_EXPORT(void) ap_kill_cleanups_for_socket(ap_context_t *p, int sock); +API_EXPORT(int) ap_psocket(ap_context_t *p, int, int, int); +API_EXPORT(int) ap_pclosesocket(ap_context_t *a, int sock); /* routines to note closes... file descriptors are constrained enough * on some systems that we want to support this. */ -API_EXPORT(int) ap_pfclose(ap_pool_t *, FILE *); -API_EXPORT(int) ap_pclosef(ap_pool_t *, int fd); +API_EXPORT(int) ap_pfclose(ap_context_t *, FILE *); +API_EXPORT(int) ap_pclosef(ap_context_t *, int fd); /* routines to deal with directories */ -/*API_EXPORT(DIR *) ap_popendir(ap_pool_t *p, const char *name); -API_EXPORT(void) ap_pclosedir(ap_pool_t *p, DIR * d); +/*API_EXPORT(DIR *) ap_popendir(ap_context_t *p, const char *name); +API_EXPORT(void) ap_pclosedir(ap_context_t *p, DIR * d); */ /* ... even child processes (which we may want to wait for, * or to kill outright, on unexpected termination). @@ -293,7 +319,7 @@ API_EXPORT(void) ap_pclosedir(ap_pool_t *p, DIR * d); API_EXPORT(void) ap_note_subprocess(struct context_t *a, pid_t pid, enum kill_conditions how); -/* magic numbers --- min free bytes to consider a free pool block useable, +/* magic numbers --- min free bytes to consider a free ap_context_t block useable, * and the min amount to allocate if we have to go to malloc() */ #ifndef BLOCK_MINFREE diff --git a/include/arch/unix/threadproc.h b/include/arch/unix/threadproc.h index fc9755011..81c9f67a1 100644 --- a/include/arch/unix/threadproc.h +++ b/include/arch/unix/threadproc.h @@ -96,7 +96,7 @@ struct proc_t { struct procattr_t *attr; }; -/*This will move to apr_threadproc.h in time, but I need to figure it out +/*This will move to ap_threadproc.h in time, but I need to figure it out * on windows first. :) */ ap_status_t ap_detach(ap_context_t *, struct proc_t **); diff --git a/lib/apr_cpystrn.c b/lib/apr_cpystrn.c index ed24b600a..f9718360d 100644 --- a/lib/apr_cpystrn.c +++ b/lib/apr_cpystrn.c @@ -74,10 +74,10 @@ * the destination string, we return a pointer to the * terminating '\0' to allow us to "check" for truncation * - * apr_cpystrn() follows the same call structure as strncpy(). + * ap_cpystrn() follows the same call structure as strncpy(). */ -API_EXPORT(char *) apr_cpystrn(char *dst, const char *src, size_t dst_size) +API_EXPORT(char *) ap_cpystrn(char *dst, const char *src, size_t dst_size) { char *d, *end; diff --git a/lib/apr_execve.c b/lib/apr_execve.c index d584a8551..612446e0b 100644 --- a/lib/apr_execve.c +++ b/lib/apr_execve.c @@ -112,7 +112,7 @@ static const char **hashbang(const char *filename, char **argv); * local argv[] array. The va_arg logic makes sure we do the right thing. * XXX: malloc() is used because we expect to be overlaid soon. */ -int apr_execle(const char *filename, const char *argv0, ...) +int ap_execle(const char *filename, const char *argv0, ...) { va_list adummy; char **envp; @@ -127,7 +127,7 @@ int apr_execle(const char *filename, const char *argv0, ...) va_end(adummy); if ((argv = (char **) malloc((argc + 2) * sizeof(*argv))) == NULL) { - fprintf(stderr, "Ouch! Out of memory in apr_execle()!\n"); + fprintf(stderr, "Ouch! Out of memory in ap_execle()!\n"); return -1; } @@ -140,7 +140,7 @@ int apr_execle(const char *filename, const char *argv0, ...) envp = va_arg(adummy, char **); va_end(adummy); - ret = apr_execve(filename, argv, envp); + ret = ap_execve(filename, argv, envp); free(argv); return ret; @@ -163,7 +163,7 @@ count_args(const char **args) * We have to fiddle with the argv array to make it work on platforms * which don't support the "hashbang" interpreter line by default. */ -int apr_execve(const char *filename, const char *argv[], +int ap_execve(const char *filename, const char *argv[], const char *envp[]) { const char **script_argv; @@ -225,7 +225,7 @@ int apr_execve(const char *filename, const char *argv[], int i = count_args(argv) + 1; /* +1 for leading SHELL_PATH */ if ((script_argv = malloc(sizeof(*script_argv) * i)) == NULL) { - fprintf(stderr, "Ouch! Out of memory in apr_execve()!\n"); + fprintf(stderr, "Ouch! Out of memory in ap_execve()!\n"); return -1; } @@ -233,7 +233,7 @@ int apr_execve(const char *filename, const char *argv[], while (i > 0) { script_argv[i] = argv[i-1]; - --i; + - ap_context_t ; } execve(SHELL_PATH, script_argv, envp); @@ -385,6 +385,6 @@ static const char **hashbang(const char *filename, char **argv) return NULL; } #else -extern void apr_execve_is_not_here(void); -void apr_execve_is_not_here(void) {} +extern void ap_execve_is_not_here(void); +void ap_execve_is_not_here(void) {} #endif /* NEED_HASHBANG_EMUL */ diff --git a/lib/apr_fnmatch.c b/lib/apr_fnmatch.c index c06b08142..cf7a9c61c 100644 --- a/lib/apr_fnmatch.c +++ b/lib/apr_fnmatch.c @@ -53,7 +53,7 @@ static char sccsid[] = "@(#)fnmatch.c 8.2 (Berkeley) 4/16/94"; static const char *rangematch(const char *, int, int); -API_EXPORT(int) apr_fnmatch(const char *pattern, const char *string, int flags) +API_EXPORT(int) ap_fnmatch(const char *pattern, const char *string, int flags) { const char *stringstart; char c, test; @@ -107,7 +107,7 @@ API_EXPORT(int) apr_fnmatch(const char *pattern, const char *string, int flags) /* General case, use recursion. */ while ((test = *string) != EOS) { - if (!apr_fnmatch(pattern, string, flags & ~FNM_PERIOD)) { + if (!ap_fnmatch(pattern, string, flags & ~FNM_PERIOD)) { return (0); } if (test == '/' && flags & FNM_PATHNAME) { @@ -143,7 +143,7 @@ API_EXPORT(int) apr_fnmatch(const char *pattern, const char *string, int flags) /* FALLTHROUGH */ default: if (flags & FNM_CASE_BLIND) { - if (apr_tolower(c) != apr_tolower(*string)) { + if (ap_tolower(c) != ap_tolower(*string)) { return (FNM_NOMATCH); } } @@ -190,14 +190,14 @@ static const char *rangematch(const char *pattern, int test, int flags) } if ((c <= test && test <= c2) || ((flags & FNM_CASE_BLIND) - && ((apr_tolower(c) <= apr_tolower(test)) - && (apr_tolower(test) <= apr_tolower(c2))))) { + && ((ap_tolower(c) <= ap_tolower(test)) + && (ap_tolower(test) <= ap_tolower(c2))))) { ok = 1; } } else if ((c == test) || ((flags & FNM_CASE_BLIND) - && (apr_tolower(c) == apr_tolower(test)))) { + && (ap_tolower(c) == ap_tolower(test)))) { ok = 1; } } @@ -207,7 +207,7 @@ static const char *rangematch(const char *pattern, int test, int flags) /* This function is an Apache addition */ /* return non-zero if pattern has any glob chars in it */ -API_EXPORT(int) apr_is_fnmatch(const char *pattern) +API_EXPORT(int) ap_is_fnmatch(const char *pattern) { int nesting; diff --git a/lib/apr_getpass.c b/lib/apr_getpass.c index 649fe7b6b..48d5bf84a 100644 --- a/lib/apr_getpass.c +++ b/lib/apr_getpass.c @@ -155,7 +155,7 @@ static char *getpass(const char *prompt) #else /* - * Windows lacks getpass(). So we'll re-implement it here. + * Windows lacks getpass(). So we'll re ap_context_t mplement it here. */ static char *getpass(const char *prompt) @@ -215,7 +215,7 @@ API_EXPORT(ap_status_t) ap_getpass(const char *prompt, char *pwbuf, size_t *bufs *bufsiz = ERR_OVERFLOW; return APR_ENAMETOOLONG; } - apr_cpystrn(pwbuf, pw_got, *bufsiz); + ap_cpystrn(pwbuf, pw_got, *bufsiz); *bufsiz = result; return APR_SUCCESS; } diff --git a/lib/apr_md5.c b/lib/apr_md5.c index e41cfde2a..18b7e4953 100644 --- a/lib/apr_md5.c +++ b/lib/apr_md5.c @@ -89,7 +89,7 @@ */ /* - * The apr_MD5Encode() routine uses much code obtained from the FreeBSD 3.0 + * The ap_MD5Encode() routine uses much code obtained from the FreeBSD 3.0 * MD5 crypt() function, which is licenced as follows: * ---------------------------------------------------------------------------- * "THE BEER-WARE LICENSE" (Revision 42): @@ -178,7 +178,7 @@ static unsigned char PADDING[64] = /* MD5 initialization. Begins an MD5 operation, writing a new context. */ -API_EXPORT(void) apr_MD5Init(APR_MD5_CTX * context) +API_EXPORT(void) ap_MD5Init(APR_MD5_CTX * context) { context->count[0] = context->count[1] = 0; /* Load magic initialization constants. */ @@ -192,7 +192,7 @@ API_EXPORT(void) apr_MD5Init(APR_MD5_CTX * context) operation, processing another message block, and updating the context. */ -API_EXPORT(void) apr_MD5Update(APR_MD5_CTX * context, const unsigned char *input, +API_EXPORT(void) ap_MD5Update(APR_MD5_CTX * context, const unsigned char *input, unsigned int inputLen) { unsigned int i, idx, partLen; @@ -247,7 +247,7 @@ API_EXPORT(void) apr_MD5Update(APR_MD5_CTX * context, const unsigned char *input /* MD5 finalization. Ends an MD5 message-digest operation, writing the the message digest and zeroizing the context. */ -API_EXPORT(void) apr_MD5Final(unsigned char digest[16], APR_MD5_CTX * context) +API_EXPORT(void) ap_MD5Final(unsigned char digest[16], APR_MD5_CTX * context) { unsigned char bits[8]; unsigned int idx, padLen; @@ -259,13 +259,13 @@ API_EXPORT(void) apr_MD5Final(unsigned char digest[16], APR_MD5_CTX * context) #ifdef CHARSET_EBCDIC /* XXX: @@@: In order to make this no more complex than necessary, * this kludge converts the bits[] array using the ascii-to-ebcdic - * table, because the following apr_MD5Update() re-translates + * table, because the following ap_MD5Update() re-translates * its input (ebcdic-to-ascii). - * Otherwise, we would have to pass a "conversion" flag to apr_MD5Update() + * Otherwise, we would have to pass a "conversion" flag to ap_MD5Update() */ ascii2ebcdic(bits,bits,8); - /* Since everything is converted to ascii within apr_MD5Update(), + /* Since everything is converted to ascii within ap_MD5Update(), * the initial 0x80 (PADDING[0]) must be stored as 0x20 */ PADDING[0] = os_toebcdic[0x80]; @@ -274,10 +274,10 @@ API_EXPORT(void) apr_MD5Final(unsigned char digest[16], APR_MD5_CTX * context) /* Pad out to 56 mod 64. */ idx = (unsigned int) ((context->count[0] >> 3) & 0x3f); padLen = (idx < 56) ? (56 - idx) : (120 - idx); - apr_MD5Update(context, PADDING, padLen); + ap_MD5Update(context, PADDING, padLen); /* Append length (before padding) */ - apr_MD5Update(context, bits, 8); + ap_MD5Update(context, bits, 8); /* Store state in digest */ Encode(digest, context->state, 16); @@ -426,7 +426,7 @@ static void to64(char *s, unsigned long v, int n) } } -API_EXPORT(void) apr_MD5Encode(const char *pw, const char *salt, +API_EXPORT(void) ap_MD5Encode(const char *pw, const char *salt, char *result, size_t nbytes) { /* @@ -471,33 +471,33 @@ API_EXPORT(void) apr_MD5Encode(const char *pw, const char *salt, /* * 'Time to make the doughnuts..' */ - apr_MD5Init(&ctx); + ap_MD5Init(&ctx); /* * The password first, since that is what is most unknown */ - apr_MD5Update(&ctx, pw, strlen(pw)); + ap_MD5Update(&ctx, pw, strlen(pw)); /* * Then our magic string */ - apr_MD5Update(&ctx, apr1_id, strlen(apr1_id)); + ap_MD5Update(&ctx, apr1_id, strlen(apr1_id)); /* * Then the raw salt */ - apr_MD5Update(&ctx, sp, sl); + ap_MD5Update(&ctx, sp, sl); /* * Then just as many characters of the MD5(pw, salt, pw) */ - apr_MD5Init(&ctx1); - apr_MD5Update(&ctx1, pw, strlen(pw)); - apr_MD5Update(&ctx1, sp, sl); - apr_MD5Update(&ctx1, pw, strlen(pw)); - apr_MD5Final(final, &ctx1); + ap_MD5Init(&ctx1); + ap_MD5Update(&ctx1, pw, strlen(pw)); + ap_MD5Update(&ctx1, sp, sl); + ap_MD5Update(&ctx1, pw, strlen(pw)); + ap_MD5Final(final, &ctx1); for(pl = strlen(pw); pl > 0; pl -= 16) { - apr_MD5Update(&ctx, final, (pl > 16) ? 16 : pl); + ap_MD5Update(&ctx, final, (pl > 16) ? 16 : pl); } /* @@ -510,10 +510,10 @@ API_EXPORT(void) apr_MD5Encode(const char *pw, const char *salt, */ for (i = strlen(pw); i != 0; i >>= 1) { if (i & 1) { - apr_MD5Update(&ctx, final, 1); + ap_MD5Update(&ctx, final, 1); } else { - apr_MD5Update(&ctx, pw, 1); + ap_MD5Update(&ctx, pw, 1); } } @@ -525,7 +525,7 @@ API_EXPORT(void) apr_MD5Encode(const char *pw, const char *salt, strncat(passwd, sp, sl); strcat(passwd, "$"); - apr_MD5Final(final, &ctx); + ap_MD5Final(final, &ctx); /* * And now, just to make sure things don't run too fast.. @@ -533,28 +533,28 @@ API_EXPORT(void) apr_MD5Encode(const char *pw, const char *salt, * need 30 seconds to build a 1000 entry dictionary... */ for (i = 0; i < 1000; i++) { - apr_MD5Init(&ctx1); + ap_MD5Init(&ctx1); if (i & 1) { - apr_MD5Update(&ctx1, pw, strlen(pw)); + ap_MD5Update(&ctx1, pw, strlen(pw)); } else { - apr_MD5Update(&ctx1, final, 16); + ap_MD5Update(&ctx1, final, 16); } if (i % 3) { - apr_MD5Update(&ctx1, sp, sl); + ap_MD5Update(&ctx1, sp, sl); } if (i % 7) { - apr_MD5Update(&ctx1, pw, strlen(pw)); + ap_MD5Update(&ctx1, pw, strlen(pw)); } if (i & 1) { - apr_MD5Update(&ctx1, final, 16); + ap_MD5Update(&ctx1, final, 16); } else { - apr_MD5Update(&ctx1, pw, strlen(pw)); + ap_MD5Update(&ctx1, pw, strlen(pw)); } - apr_MD5Final(final,&ctx1); + ap_MD5Final(final,&ctx1); } p = passwd + strlen(passwd); @@ -572,17 +572,17 @@ API_EXPORT(void) apr_MD5Encode(const char *pw, const char *salt, */ memset(final, 0, sizeof(final)); - apr_cpystrn(result, passwd, nbytes - 1); + ap_cpystrn(result, passwd, nbytes - 1); } /* * Validate a plaintext password against a smashed one. Use either - * crypt() (if available) or apr_MD5Encode(), depending upon the format + * crypt() (if available) or ap_MD5Encode(), depending upon the format * of the smashed input password. Return NULL if they match, or * an explanatory text string if they don't. */ -API_EXPORT(char *) apr_validate_password(const char *passwd, const char *hash) +API_EXPORT(char *) ap_validate_password(const char *passwd, const char *hash) { char sample[120]; #ifndef WIN32 @@ -592,17 +592,17 @@ API_EXPORT(char *) apr_validate_password(const char *passwd, const char *hash) /* * The hash was created using our custom algorithm. */ - apr_MD5Encode(passwd, hash, sample, sizeof(sample)); + ap_MD5Encode(passwd, hash, sample, sizeof(sample)); } else { /* * It's not our algorithm, so feed it to crypt() if possible. */ #ifdef WIN32 - apr_cpystrn(sample, passwd, sizeof(sample) - 1); + ap_cpystrn(sample, passwd, sizeof(sample) - 1); #else crypt_pw = crypt(passwd, hash); - apr_cpystrn(sample, crypt_pw, sizeof(sample) - 1); + ap_cpystrn(sample, crypt_pw, sizeof(sample) - 1); #endif } return (strcmp(sample, hash) == 0) ? NULL : "password mismatch"; diff --git a/lib/apr_pools.c b/lib/apr_pools.c index afe3b8d49..27f1fe2a5 100644 --- a/lib/apr_pools.c +++ b/lib/apr_pools.c @@ -72,6 +72,11 @@ #include "apr_pools.h" #include "apr_lib.h" #include "misc.h" +#include <sys/stat.h> +#include <sys/types.h> +#include <dirent.h> +#include <fcntl.h> + #ifdef HAVE_STDLIB_H #include <stdlib.h> #endif @@ -106,9 +111,9 @@ /* * Pool debugging support: This is intended to detect cases where the - * wrong pool is used when assigning data to an object in another pool. + * wrong ap_context_t is used when assigning data to an object in another pool. * In particular, it causes the table_{set,add,merge}n routines to check - * that their arguments are safe for the table they're being placed in. + * that their arguments are safe for the ap_table_t they're being placed in. * It currently only works with the unix multiprocess model, but could * be extended to others. */ @@ -119,10 +124,10 @@ * possibly too small. This requires a recent gcc which supports * __builtin_return_address(). The error_log output will be a * message such as: - * table_push: table created by 0x804d874 hit limit of 10 + * table_push: ap_table_t created by 0x804d874 hit limit of 10 * Use "l *0x804d874" to find the source that corresponds to. It - * indicates that a table allocated by a call at that address has - * possibly too small an initial table size guess. + * indicates that a ap_table_t allocated by a call at that address has + * possibly too small an initial ap_table_t size guess. */ /* #define MAKE_TABLE_PROFILE */ @@ -150,6 +155,10 @@ #define BLOCK_MINALLOC 0 #endif /* ALLOC_USE_MALLOC */ +#define AP_SLACK_LOW 1 +#define AP_SLACK_HIGH 2 + + /***************************************************************** * * Managing free storage blocks... @@ -444,7 +453,7 @@ static void free_proc_chain(struct process_chain *p); static ap_pool_t *permanent_pool; -/* Each pool structure is allocated in the start of its own first block, +/* Each ap_context_t structure is allocated in the start of its own first block, * so we need to know how many bytes that is (once properly aligned...). * This also means that when a pool's sub-pool is destroyed, the storage * associated with it is *completely* gone, so we have to make sure it @@ -536,68 +545,80 @@ ap_pool_t *ap_init_alloc(void) return permanent_pool; } -API_EXPORT(void) ap_clear_pool(struct context_t *a) +void ap_destroy_real_pool(ap_pool_t *); + +void ap_clear_real_pool(ap_pool_t *a) { ap_block_alarms(); (void) ap_acquire_mutex(alloc_mutex); - while (a->pool->sub_pools) { - ap_destroy_pool(a); + while (a->sub_pools) { + ap_destroy_real_pool(a->sub_pools); } (void) ap_release_mutex(alloc_mutex); /* * Don't hold the mutex during cleanups. */ - run_cleanups(a->pool->cleanups); - a->pool->cleanups = NULL; - free_proc_chain(a->pool->subprocesses); - a->pool->subprocesses = NULL; - free_blocks(a->pool->first->h.next); - a->pool->first->h.next = NULL; - - a->pool->last = a->pool->first; - a->pool->first->h.first_avail = a->pool->free_first_avail; - debug_fill(a->pool->first->h.first_avail, - a->pool->first->h.endp - a->pool->first->h.first_avail); + run_cleanups(a->cleanups); + a->cleanups = NULL; + free_proc_chain(a->subprocesses); + a->subprocesses = NULL; + free_blocks(a->first->h.next); + a->first->h.next = NULL; + + a->last = a->first; + a->first->h.first_avail = a->free_first_avail; + debug_fill(a->first->h.first_avail, + a->first->h.endp - a->first->h.first_avail); #ifdef ALLOC_USE_MALLOC { void *c, *n; - for (c = a->pool->allocation_list; c; c = n) { + for (c = a->allocation_list; c; c = n) { n = *(void **)c; free(c); } - a->pool->allocation_list = NULL; + a->allocation_list = NULL; } #endif ap_unblock_alarms(); } -API_EXPORT(void) ap_destroy_pool(struct context_t *a) +API_EXPORT(void) ap_clear_pool(struct context_t *a) +{ + ap_clear_real_pool(a->pool); +} + +API_EXPORT(void) ap_destroy_real_pool(ap_pool_t *a) { ap_block_alarms(); - ap_clear_pool(a); + ap_clear_real_pool(a); (void) ap_acquire_mutex(alloc_mutex); - if (a->pool->parent) { - if (a->pool->parent->sub_pools == a->pool) { - a->pool->parent->sub_pools = a->pool->sub_next; + if (a->parent) { + if (a->parent->sub_pools == a) { + a->parent->sub_pools = a->sub_next; } - if (a->pool->sub_prev) { - a->pool->sub_prev->sub_next = a->pool->sub_next; + if (a->sub_prev) { + a->sub_prev->sub_next = a->sub_next; } - if (a->pool->sub_next) { - a->pool->sub_next->sub_prev = a->pool->sub_prev; + if (a->sub_next) { + a->sub_next->sub_prev = a->sub_prev; } } (void) ap_release_mutex(alloc_mutex); - free_blocks(a->pool->first); + free_blocks(a->first); ap_unblock_alarms(); } +API_EXPORT(void) ap_destroy_pool(struct context_t *a) +{ + ap_destroy_real_pool(a->pool); +} + API_EXPORT(long) ap_bytes_in_pool(ap_pool_t *p) { return bytes_in_block_list(p->first); @@ -622,7 +643,7 @@ extern char _end; (((unsigned long)(ptr) - (unsigned long)(lo)) \ < (unsigned long)(hi) - (unsigned long)(lo)) -/* Find the pool that ts belongs to, return NULL if it doesn't +/* Find the ap_context_t that ts belongs to, return NULL if it doesn't * belong to any pool. */ API_EXPORT(ap_pool_t *) ap_find_pool(const void *ts) @@ -882,7 +903,7 @@ API_EXPORT_NONSTD(char *) ap_pstrcat(struct context_t *a, ...) * until all the output is done. * * Note that this is completely safe because nothing else can - * allocate in this pool while ap_psprintf is running. alarms are + * allocate in this ap_context_t while ap_psprintf is running. alarms are * blocked, and the only thing outside of alloc.c that's invoked * is ap_vformatter -- which was purposefully written to be * self-contained with no callouts. @@ -945,7 +966,7 @@ static int psprintf_flush(ap_vformatter_buff_t *vbuff) ps->blok = nblok; ps->got_a_new_block = 1; /* note that we've deliberately not linked the new block onto - * the pool yet... because we may need to flush again later, and + * the ap_context_t yet... because we may need to flush again later, and * we'd have to spend more effort trying to unlink the block. */ return 0; @@ -1123,7 +1144,7 @@ API_EXPORT(void) ap_cleanup_for_exec(void) #endif /* ndef WIN32 */ } -API_EXPORT_NONSTD(void) ap_null_cleanup(void *data) +API_EXPORT_NONSTD(ap_status_t) ap_null_cleanup(void *data) { /* do nothing cleanup routine */ } @@ -1133,23 +1154,23 @@ API_EXPORT_NONSTD(void) ap_null_cleanup(void *data) * Files and file descriptors; these are just an application of the * generic cleanup interface. */ -#if 0 /*not really needed any more, apr takes care of this stuff */ -static void fd_cleanup(void *fdv) +static ap_status_t fd_cleanup(void *fdv) { close((int) (long) fdv); + return APR_SUCCESS; } -API_EXPORT(void) ap_note_cleanups_for_fd(ap_pool_t *p, int fd) +API_EXPORT(void) ap_note_cleanups_for_fd(ap_context_t *p, int fd) { ap_register_cleanup(p, (void *) (long) fd, fd_cleanup, fd_cleanup); } -API_EXPORT(void) ap_kill_cleanups_for_fd(ap_pool_t *p, int fd) +API_EXPORT(void) ap_kill_cleanups_for_fd(ap_context_t *p, int fd) { ap_kill_cleanup(p, (void *) (long) fd, fd_cleanup); } -API_EXPORT(int) ap_popenf(ap_pool_t *a, const char *name, int flg, int mode) +API_EXPORT(int) ap_popenf(ap_context_t *a, const char *name, int flg, int mode) { int fd; int save_errno; @@ -1158,7 +1179,7 @@ API_EXPORT(int) ap_popenf(ap_pool_t *a, const char *name, int flg, int mode) fd = open(name, flg, mode); save_errno = errno; if (fd >= 0) { - fd = ap_slack(fd, ap_SLACK_HIGH); + fd = ap_slack(fd, AP_SLACK_HIGH); ap_note_cleanups_for_fd(a, fd); } ap_unblock_alarms(); @@ -1166,7 +1187,7 @@ API_EXPORT(int) ap_popenf(ap_pool_t *a, const char *name, int flg, int mode) return fd; } -API_EXPORT(int) ap_pclosef(ap_pool_t *a, int fd) +API_EXPORT(int) ap_pclosef(ap_context_t *a, int fd) { int res; int save_errno; @@ -1186,12 +1207,12 @@ static void h_cleanup(void *fdv) CloseHandle((HANDLE) fdv); } -API_EXPORT(void) ap_note_cleanups_for_h(ap_pool_t *p, HANDLE hDevice) +API_EXPORT(void) ap_note_cleanups_for_h(ap_context_t *p, HANDLE hDevice) { ap_register_cleanup(p, (void *) hDevice, h_cleanup, h_cleanup); } -API_EXPORT(int) ap_pcloseh(ap_pool_t *a, HANDLE hDevice) +API_EXPORT(int) ap_pcloseh(ap_context_t *a, HANDLE hDevice) { int res=0; int save_errno; @@ -1209,26 +1230,28 @@ API_EXPORT(int) ap_pcloseh(ap_pool_t *a, HANDLE hDevice) return res; } #endif -*/ + /* Note that we have separate plain_ and child_ cleanups for FILE *s, * since fclose() would flush I/O buffers, which is extremely undesirable; * we just close the descriptor. */ -static void file_cleanup(void *fpv) +static ap_status_t file_cleanup(void *fpv) { fclose((FILE *) fpv); + return APR_SUCCESS; } -static void file_child_cleanup(void *fpv) +static ap_status_t file_child_cleanup(void *fpv) { close(fileno((FILE *) fpv)); + return APR_SUCCESS; } -API_EXPORT(void) ap_note_cleanups_for_file(ap_pool_t *p, FILE *fp) +API_EXPORT(void) ap_note_cleanups_for_file(ap_context_t *p, FILE *fp) { ap_register_cleanup(p, (void *) fp, file_cleanup, file_child_cleanup); } -API_EXPORT(FILE *) ap_pfopen(ap_pool_t *a, const char *name, +API_EXPORT(FILE *) ap_pfopen(ap_context_t *a, const char *name, const char *mode) { FILE *fd = NULL; @@ -1250,7 +1273,7 @@ API_EXPORT(FILE *) ap_pfopen(ap_pool_t *a, const char *name, desc = open(name, baseFlag | O_APPEND | O_CREAT, modeFlags); if (desc >= 0) { - desc = ap_slack(desc, ap_SLACK_LOW); + desc = ap_slack(desc, AP_SLACK_LOW); fd = ap_fdopen(desc, mode); } } @@ -1266,7 +1289,7 @@ API_EXPORT(FILE *) ap_pfopen(ap_pool_t *a, const char *name, return fd; } -API_EXPORT(FILE *) ap_pfdopen(ap_pool_t *a, int fd, const char *mode) +API_EXPORT(FILE *) ap_pfdopen(ap_context_t *a, int fd, const char *mode) { FILE *f; int saved_errno; @@ -1283,7 +1306,7 @@ API_EXPORT(FILE *) ap_pfdopen(ap_pool_t *a, int fd, const char *mode) } -API_EXPORT(int) ap_pfclose(ap_pool_t *a, FILE *fd) +API_EXPORT(int) ap_pfclose(ap_context_t *a, FILE *fd) { int res; @@ -1298,12 +1321,13 @@ API_EXPORT(int) ap_pfclose(ap_pool_t *a, FILE *fd) * DIR * with cleanup */ -static void dir_cleanup(void *dv) +static ap_status_t dir_cleanup(void *dv) { closedir((DIR *) dv); + return APR_SUCCESS; } -API_EXPORT(DIR *) ap_popendir(ap_pool_t *p, const char *name) +API_EXPORT(DIR *) ap_popendir(ap_context_t *p, const char *name) { DIR *d; int save_errno; @@ -1321,7 +1345,7 @@ API_EXPORT(DIR *) ap_popendir(ap_pool_t *p, const char *name) return d; } -API_EXPORT(void) ap_pclosedir(ap_pool_t *p, DIR * d) +API_EXPORT(void) ap_pclosedir(ap_context_t *p, DIR * d) { ap_block_alarms(); ap_kill_cleanup(p, (void *) d, dir_cleanup); @@ -1335,23 +1359,24 @@ API_EXPORT(void) ap_pclosedir(ap_pool_t *p, DIR * d) * generic cleanup interface. */ -static void socket_cleanup(void *fdv) +static ap_status_t socket_cleanup(void *fdv) { closesocket((int) (long) fdv); + return APR_SUCCESS; } -API_EXPORT(void) ap_note_cleanups_for_socket(ap_pool_t *p, int fd) +API_EXPORT(void) ap_note_cleanups_for_socket(ap_context_t *p, int fd) { ap_register_cleanup(p, (void *) (long) fd, socket_cleanup, socket_cleanup); } -API_EXPORT(void) ap_kill_cleanups_for_socket(ap_pool_t *p, int sock) +API_EXPORT(void) ap_kill_cleanups_for_socket(ap_context_t *p, int sock) { ap_kill_cleanup(p, (void *) (long) sock, socket_cleanup); } -API_EXPORT(int) ap_psocket(ap_pool_t *p, int domain, int type, int protocol) +API_EXPORT(int) ap_psocket(ap_context_t *p, int domain, int type, int protocol) { int fd; @@ -1368,7 +1393,7 @@ API_EXPORT(int) ap_psocket(ap_pool_t *p, int domain, int type, int protocol) return fd; } -API_EXPORT(int) ap_pclosesocket(ap_pool_t *a, int sock) +API_EXPORT(int) ap_pclosesocket(ap_context_t *a, int sock) { int res; int save_errno; @@ -1394,12 +1419,13 @@ API_EXPORT(int) ap_pclosesocket(ap_pool_t *a, int sock) * regfree() doesn't clear it. So we don't allow it. */ -static void regex_cleanup(void *preg) +static ap_status_t regex_cleanup(void *preg) { regfree((regex_t *) preg); + return APR_SUCCESS; } -API_EXPORT(regex_t *) ap_pregcomp(ap_pool_t *p, const char *pattern, +API_EXPORT(regex_t *) ap_pregcomp(ap_context_t *p, const char *pattern, int cflags) { regex_t *preg = ap_palloc(p, sizeof(regex_t)); @@ -1408,20 +1434,21 @@ API_EXPORT(regex_t *) ap_pregcomp(ap_pool_t *p, const char *pattern, return NULL; } - ap_register_cleanup(p, (void *) preg, regex_cleanup, regex_cleanup); +/* ap_register_cleanup(p, (void *) preg, regex_cleanup, regex_cleanup);*/ + ap_register_cleanup(p, (void *) preg, ap_null_cleanup, ap_null_cleanup); return preg; } -API_EXPORT(void) ap_pregfree(ap_pool_t *p, regex_t * reg) +API_EXPORT(void) ap_pregfree(ap_context_t *p, regex_t * reg) { ap_block_alarms(); regfree(reg); ap_kill_cleanup(p, (void *) reg, regex_cleanup); ap_unblock_alarms(); } -#endif /* if 0 not really needed anymore. APR takes care of this. */ + /***************************************************************** * * More grotty system stuff... subprocesses. Frump. These don't use @@ -1458,8 +1485,8 @@ API_EXPORT(void) ap_note_subprocess(struct context_t *a, pid_t pid, #define BINMODE #endif -#if 0 -static pid_t spawn_child_core(ap_pool_t *p, + +static pid_t spawn_child_core(ap_context_t *p, int (*func) (void *, ap_child_info_t *), void *data,enum kill_conditions kill_how, int *pipe_in, int *pipe_out, int *pipe_err) @@ -1716,7 +1743,7 @@ static pid_t spawn_child_core(ap_pool_t *p, } -API_EXPORT(int) ap_spawn_child(ap_pool_t *p, +API_EXPORT(int) ap_spawn_child(ap_context_t *p, int (*func) (void *v, ap_child_info_t *c), void *data, enum kill_conditions kill_how, FILE **pipe_in, FILE **pipe_out, @@ -1773,7 +1800,7 @@ API_EXPORT(int) ap_spawn_child(ap_pool_t *p, ap_unblock_alarms(); return pid; } - +#if 0 API_EXPORT(int) ap_bspawn_child(ap_pool_t *p, int (*func) (void *v, ap_child_info_t *c), void *data, enum kill_conditions kill_how, diff --git a/lib/apr_signal.c b/lib/apr_signal.c index b4b361f02..0e9c118c2 100644 --- a/lib/apr_signal.c +++ b/lib/apr_signal.c @@ -80,5 +80,5 @@ Sigfunc *signal(int signo, Sigfunc * func) } #else /* need some function in this file, otherwise the linker on NeXT bitches */ -void apr_signal_is_not_here(void) {} +void ap_signal_is_not_here(void) {} #endif diff --git a/lib/apr_slack.c b/lib/apr_slack.c index 8df9c8847..30ebacae9 100644 --- a/lib/apr_slack.c +++ b/lib/apr_slack.c @@ -56,7 +56,7 @@ */ /* - * apr_slack.c: File descriptor preallocation + * ap_slack.c: File descriptor preallocation * * 3/21/93 Rob McCool * 1995-96 Many changes by the Apache Group @@ -74,7 +74,7 @@ #endif #ifndef NO_SLACK -int apr_slack(int fd, int line) +int ap_slack(int fd, int line) { #if !defined(F_DUPFD) return fd; @@ -107,7 +107,7 @@ int apr_slack(int fd, int line) * the high line, because if it fails we'll eventually try * the low line... */ - apr_log_error(APLOG_MARK, APLOG_WARNING, NULL, + ap_log_error(APLOG_MARK, APLOG_WARNING, NULL, "unable to open a file descriptor above %u, " "you may need to increase the number of descriptors", LOW_SLACK_LINE); @@ -122,5 +122,5 @@ int apr_slack(int fd, int line) } #else /* need at least one function in the file for some linkers */ -void apr_slack_is_not_here(void) {} +void ap_slack_is_not_here(void) {} #endif /* NO_SLACK */ diff --git a/lib/apr_tables.c b/lib/apr_tables.c index ccc16a298..53d072c9d 100644 --- a/lib/apr_tables.c +++ b/lib/apr_tables.c @@ -80,7 +80,7 @@ #endif /***************************************************************** - * This file contains array and table functions only. + * This file contains array and ap_table_t functions only. */ /***************************************************************** @@ -210,7 +210,7 @@ API_EXPORT(ap_array_header_t *) return res; } -/* ap_array_pstrcat generates a new string from the pool containing +/* ap_array_pstrcat generates a new string from the ap_context_t containing * the concatenated sequence of substrings referenced as elements within * the array. The string will be empty if all substrings are empty or null, * or if there are no elements in the array. @@ -285,7 +285,7 @@ static ap_table_entry_t *table_push(ap_table_t *t) { if (t->a.nelts == t->a.nalloc) { fprintf(stderr, - "table_push: table created by %p hit limit of %u\n", + "table_push: ap_table_t created by %p hit limit of %u\n", t->creator, t->a.nalloc); } return (ap_table_entry_t *) ap_push_array(&t->a); @@ -315,7 +315,7 @@ API_EXPORT(ap_table_t *) ap_copy_table(struct context_t *p, const ap_table_t *t) * have a life span at least as long as p */ if (!ap_pool_is_ancestor(t->a.pool, p)) { - fprintf(stderr, "copy_table: t's pool is not an ancestor of p\n"); + fprintf(stderr, "copy_table: t's ap_context_t is not an ancestor of p\n"); abort(); } #endif @@ -392,11 +392,11 @@ API_EXPORT(void) ap_table_setn(ap_table_t *t, const char *key, #ifdef POOL_DEBUG { if (!ap_pool_is_ancestor(ap_find_pool(key), t->a.pool)) { - fprintf(stderr, "table_set: key not in ancestor pool of t\n"); + fprintf(stderr, "table_set: key not in ancestor ap_context_t of t\n"); abort(); } if (!ap_pool_is_ancestor(ap_find_pool(val), t->a.pool)) { - fprintf(stderr, "table_set: val not in ancestor pool of t\n"); + fprintf(stderr, "table_set: val not in ancestor ap_context_t of t\n"); abort(); } } @@ -481,11 +481,11 @@ API_EXPORT(void) ap_table_mergen(ap_table_t *t, const char *key, #ifdef POOL_DEBUG { if (!ap_pool_is_ancestor(ap_find_pool(key), t->a.pool)) { - fprintf(stderr, "table_set: key not in ancestor pool of t\n"); + fprintf(stderr, "table_set: key not in ancestor ap_context_t of t\n"); abort(); } if (!ap_pool_is_ancestor(ap_find_pool(val), t->a.pool)) { - fprintf(stderr, "table_set: key not in ancestor pool of t\n"); + fprintf(stderr, "table_set: key not in ancestor ap_context_t of t\n"); abort(); } } @@ -521,11 +521,11 @@ API_EXPORT(void) ap_table_addn(ap_table_t *t, const char *key, #ifdef POOL_DEBUG { if (!ap_pool_is_ancestor(ap_find_pool(key), t->a.pool)) { - fprintf(stderr, "table_set: key not in ancestor pool of t\n"); + fprintf(stderr, "table_set: key not in ancestor ap_context_t of t\n"); abort(); } if (!ap_pool_is_ancestor(ap_find_pool(val), t->a.pool)) { - fprintf(stderr, "table_set: key not in ancestor pool of t\n"); + fprintf(stderr, "table_set: key not in ancestor ap_context_t of t\n"); abort(); } } @@ -549,12 +549,12 @@ API_EXPORT(ap_table_t *) ap_overlay_tables(struct context_t *p, */ if (!ap_pool_is_ancestor(overlay->a.pool, p->pool)) { fprintf(stderr, - "overlay_tables: overlay's pool is not an ancestor of p\n"); + "overlay_tables: overlay's ap_context_t is not an ancestor of p\n"); abort(); } if (!ap_pool_is_ancestor(base->a.pool, p->pool)) { fprintf(stderr, - "overlay_tables: base's pool is not an ancestor of p\n"); + "overlay_tables: base's ap_context_t is not an ancestor of p\n"); abort(); } #endif @@ -573,7 +573,7 @@ API_EXPORT(ap_table_t *) ap_overlay_tables(struct context_t *p, * For each key value given as a vararg: * run the function pointed to as * int comp(void *r, char *key, char *value); - * on each valid key-value pair in the table t that matches the vararg key, + * on each valid key-value pair in the ap_table_t t that matches the vararg key, * or once for every valid key-value pair if the vararg list is empty, * until the function returns false (0) or we finish the table. * @@ -583,7 +583,7 @@ API_EXPORT(ap_table_t *) ap_overlay_tables(struct context_t *p, * only one traversal will be made and will cut short if comp returns 0. * * Note that the table_get and table_merge functions assume that each key in - * the table is unique (i.e., no multiple entries with the same key). This + * the ap_table_t is unique (i.e., no multiple entries with the same key). This * function does not make that assumption, since it (unfortunately) isn't * true for some of Apache's tables. * @@ -662,7 +662,7 @@ API_EXPORT(void) ap_overlap_tables(ap_table_t *a, const ap_table_t *b, cat_keys = cat_keys_buf; } else { - /* XXX: could use scratch free space in a or b's pool instead... + /* XXX: could use scratch free space in a or b's ap_context_t instead... * which could save an allocation in b's pool. */ cat_keys = ap_palloc(b->a.cont, sizeof(overlap_key) * nkeys); diff --git a/locks/unix/crossproc.c b/locks/unix/crossproc.c index 3c2aeb511..51d33c137 100644 --- a/locks/unix/crossproc.c +++ b/locks/unix/crossproc.c @@ -86,7 +86,7 @@ ap_status_t create_inter_lock(struct lock_t *new) lock_cleanup(new); return errno; } - /* pre-initialize these */ + /* pre ap_context_t nitialize these */ new->op_on.sem_num = 0; new->op_on.sem_op = -1; new->op_on.sem_flg = SEM_UNDO; @@ -248,7 +248,7 @@ ap_status_t create_inter_lock(struct lock_t *new) lock_cleanup(new); return errno; } - /* pre-initialize these */ + /* pre ap_context_t nitialize these */ new->lock_it.l_whence = SEEK_SET; /* from current point */ new->lock_it.l_start = 0; /* -"- */ new->lock_it.l_len = 0; /* until end of file */ diff --git a/memory/unix/apr_pools.c b/memory/unix/apr_pools.c index afe3b8d49..27f1fe2a5 100644 --- a/memory/unix/apr_pools.c +++ b/memory/unix/apr_pools.c @@ -72,6 +72,11 @@ #include "apr_pools.h" #include "apr_lib.h" #include "misc.h" +#include <sys/stat.h> +#include <sys/types.h> +#include <dirent.h> +#include <fcntl.h> + #ifdef HAVE_STDLIB_H #include <stdlib.h> #endif @@ -106,9 +111,9 @@ /* * Pool debugging support: This is intended to detect cases where the - * wrong pool is used when assigning data to an object in another pool. + * wrong ap_context_t is used when assigning data to an object in another pool. * In particular, it causes the table_{set,add,merge}n routines to check - * that their arguments are safe for the table they're being placed in. + * that their arguments are safe for the ap_table_t they're being placed in. * It currently only works with the unix multiprocess model, but could * be extended to others. */ @@ -119,10 +124,10 @@ * possibly too small. This requires a recent gcc which supports * __builtin_return_address(). The error_log output will be a * message such as: - * table_push: table created by 0x804d874 hit limit of 10 + * table_push: ap_table_t created by 0x804d874 hit limit of 10 * Use "l *0x804d874" to find the source that corresponds to. It - * indicates that a table allocated by a call at that address has - * possibly too small an initial table size guess. + * indicates that a ap_table_t allocated by a call at that address has + * possibly too small an initial ap_table_t size guess. */ /* #define MAKE_TABLE_PROFILE */ @@ -150,6 +155,10 @@ #define BLOCK_MINALLOC 0 #endif /* ALLOC_USE_MALLOC */ +#define AP_SLACK_LOW 1 +#define AP_SLACK_HIGH 2 + + /***************************************************************** * * Managing free storage blocks... @@ -444,7 +453,7 @@ static void free_proc_chain(struct process_chain *p); static ap_pool_t *permanent_pool; -/* Each pool structure is allocated in the start of its own first block, +/* Each ap_context_t structure is allocated in the start of its own first block, * so we need to know how many bytes that is (once properly aligned...). * This also means that when a pool's sub-pool is destroyed, the storage * associated with it is *completely* gone, so we have to make sure it @@ -536,68 +545,80 @@ ap_pool_t *ap_init_alloc(void) return permanent_pool; } -API_EXPORT(void) ap_clear_pool(struct context_t *a) +void ap_destroy_real_pool(ap_pool_t *); + +void ap_clear_real_pool(ap_pool_t *a) { ap_block_alarms(); (void) ap_acquire_mutex(alloc_mutex); - while (a->pool->sub_pools) { - ap_destroy_pool(a); + while (a->sub_pools) { + ap_destroy_real_pool(a->sub_pools); } (void) ap_release_mutex(alloc_mutex); /* * Don't hold the mutex during cleanups. */ - run_cleanups(a->pool->cleanups); - a->pool->cleanups = NULL; - free_proc_chain(a->pool->subprocesses); - a->pool->subprocesses = NULL; - free_blocks(a->pool->first->h.next); - a->pool->first->h.next = NULL; - - a->pool->last = a->pool->first; - a->pool->first->h.first_avail = a->pool->free_first_avail; - debug_fill(a->pool->first->h.first_avail, - a->pool->first->h.endp - a->pool->first->h.first_avail); + run_cleanups(a->cleanups); + a->cleanups = NULL; + free_proc_chain(a->subprocesses); + a->subprocesses = NULL; + free_blocks(a->first->h.next); + a->first->h.next = NULL; + + a->last = a->first; + a->first->h.first_avail = a->free_first_avail; + debug_fill(a->first->h.first_avail, + a->first->h.endp - a->first->h.first_avail); #ifdef ALLOC_USE_MALLOC { void *c, *n; - for (c = a->pool->allocation_list; c; c = n) { + for (c = a->allocation_list; c; c = n) { n = *(void **)c; free(c); } - a->pool->allocation_list = NULL; + a->allocation_list = NULL; } #endif ap_unblock_alarms(); } -API_EXPORT(void) ap_destroy_pool(struct context_t *a) +API_EXPORT(void) ap_clear_pool(struct context_t *a) +{ + ap_clear_real_pool(a->pool); +} + +API_EXPORT(void) ap_destroy_real_pool(ap_pool_t *a) { ap_block_alarms(); - ap_clear_pool(a); + ap_clear_real_pool(a); (void) ap_acquire_mutex(alloc_mutex); - if (a->pool->parent) { - if (a->pool->parent->sub_pools == a->pool) { - a->pool->parent->sub_pools = a->pool->sub_next; + if (a->parent) { + if (a->parent->sub_pools == a) { + a->parent->sub_pools = a->sub_next; } - if (a->pool->sub_prev) { - a->pool->sub_prev->sub_next = a->pool->sub_next; + if (a->sub_prev) { + a->sub_prev->sub_next = a->sub_next; } - if (a->pool->sub_next) { - a->pool->sub_next->sub_prev = a->pool->sub_prev; + if (a->sub_next) { + a->sub_next->sub_prev = a->sub_prev; } } (void) ap_release_mutex(alloc_mutex); - free_blocks(a->pool->first); + free_blocks(a->first); ap_unblock_alarms(); } +API_EXPORT(void) ap_destroy_pool(struct context_t *a) +{ + ap_destroy_real_pool(a->pool); +} + API_EXPORT(long) ap_bytes_in_pool(ap_pool_t *p) { return bytes_in_block_list(p->first); @@ -622,7 +643,7 @@ extern char _end; (((unsigned long)(ptr) - (unsigned long)(lo)) \ < (unsigned long)(hi) - (unsigned long)(lo)) -/* Find the pool that ts belongs to, return NULL if it doesn't +/* Find the ap_context_t that ts belongs to, return NULL if it doesn't * belong to any pool. */ API_EXPORT(ap_pool_t *) ap_find_pool(const void *ts) @@ -882,7 +903,7 @@ API_EXPORT_NONSTD(char *) ap_pstrcat(struct context_t *a, ...) * until all the output is done. * * Note that this is completely safe because nothing else can - * allocate in this pool while ap_psprintf is running. alarms are + * allocate in this ap_context_t while ap_psprintf is running. alarms are * blocked, and the only thing outside of alloc.c that's invoked * is ap_vformatter -- which was purposefully written to be * self-contained with no callouts. @@ -945,7 +966,7 @@ static int psprintf_flush(ap_vformatter_buff_t *vbuff) ps->blok = nblok; ps->got_a_new_block = 1; /* note that we've deliberately not linked the new block onto - * the pool yet... because we may need to flush again later, and + * the ap_context_t yet... because we may need to flush again later, and * we'd have to spend more effort trying to unlink the block. */ return 0; @@ -1123,7 +1144,7 @@ API_EXPORT(void) ap_cleanup_for_exec(void) #endif /* ndef WIN32 */ } -API_EXPORT_NONSTD(void) ap_null_cleanup(void *data) +API_EXPORT_NONSTD(ap_status_t) ap_null_cleanup(void *data) { /* do nothing cleanup routine */ } @@ -1133,23 +1154,23 @@ API_EXPORT_NONSTD(void) ap_null_cleanup(void *data) * Files and file descriptors; these are just an application of the * generic cleanup interface. */ -#if 0 /*not really needed any more, apr takes care of this stuff */ -static void fd_cleanup(void *fdv) +static ap_status_t fd_cleanup(void *fdv) { close((int) (long) fdv); + return APR_SUCCESS; } -API_EXPORT(void) ap_note_cleanups_for_fd(ap_pool_t *p, int fd) +API_EXPORT(void) ap_note_cleanups_for_fd(ap_context_t *p, int fd) { ap_register_cleanup(p, (void *) (long) fd, fd_cleanup, fd_cleanup); } -API_EXPORT(void) ap_kill_cleanups_for_fd(ap_pool_t *p, int fd) +API_EXPORT(void) ap_kill_cleanups_for_fd(ap_context_t *p, int fd) { ap_kill_cleanup(p, (void *) (long) fd, fd_cleanup); } -API_EXPORT(int) ap_popenf(ap_pool_t *a, const char *name, int flg, int mode) +API_EXPORT(int) ap_popenf(ap_context_t *a, const char *name, int flg, int mode) { int fd; int save_errno; @@ -1158,7 +1179,7 @@ API_EXPORT(int) ap_popenf(ap_pool_t *a, const char *name, int flg, int mode) fd = open(name, flg, mode); save_errno = errno; if (fd >= 0) { - fd = ap_slack(fd, ap_SLACK_HIGH); + fd = ap_slack(fd, AP_SLACK_HIGH); ap_note_cleanups_for_fd(a, fd); } ap_unblock_alarms(); @@ -1166,7 +1187,7 @@ API_EXPORT(int) ap_popenf(ap_pool_t *a, const char *name, int flg, int mode) return fd; } -API_EXPORT(int) ap_pclosef(ap_pool_t *a, int fd) +API_EXPORT(int) ap_pclosef(ap_context_t *a, int fd) { int res; int save_errno; @@ -1186,12 +1207,12 @@ static void h_cleanup(void *fdv) CloseHandle((HANDLE) fdv); } -API_EXPORT(void) ap_note_cleanups_for_h(ap_pool_t *p, HANDLE hDevice) +API_EXPORT(void) ap_note_cleanups_for_h(ap_context_t *p, HANDLE hDevice) { ap_register_cleanup(p, (void *) hDevice, h_cleanup, h_cleanup); } -API_EXPORT(int) ap_pcloseh(ap_pool_t *a, HANDLE hDevice) +API_EXPORT(int) ap_pcloseh(ap_context_t *a, HANDLE hDevice) { int res=0; int save_errno; @@ -1209,26 +1230,28 @@ API_EXPORT(int) ap_pcloseh(ap_pool_t *a, HANDLE hDevice) return res; } #endif -*/ + /* Note that we have separate plain_ and child_ cleanups for FILE *s, * since fclose() would flush I/O buffers, which is extremely undesirable; * we just close the descriptor. */ -static void file_cleanup(void *fpv) +static ap_status_t file_cleanup(void *fpv) { fclose((FILE *) fpv); + return APR_SUCCESS; } -static void file_child_cleanup(void *fpv) +static ap_status_t file_child_cleanup(void *fpv) { close(fileno((FILE *) fpv)); + return APR_SUCCESS; } -API_EXPORT(void) ap_note_cleanups_for_file(ap_pool_t *p, FILE *fp) +API_EXPORT(void) ap_note_cleanups_for_file(ap_context_t *p, FILE *fp) { ap_register_cleanup(p, (void *) fp, file_cleanup, file_child_cleanup); } -API_EXPORT(FILE *) ap_pfopen(ap_pool_t *a, const char *name, +API_EXPORT(FILE *) ap_pfopen(ap_context_t *a, const char *name, const char *mode) { FILE *fd = NULL; @@ -1250,7 +1273,7 @@ API_EXPORT(FILE *) ap_pfopen(ap_pool_t *a, const char *name, desc = open(name, baseFlag | O_APPEND | O_CREAT, modeFlags); if (desc >= 0) { - desc = ap_slack(desc, ap_SLACK_LOW); + desc = ap_slack(desc, AP_SLACK_LOW); fd = ap_fdopen(desc, mode); } } @@ -1266,7 +1289,7 @@ API_EXPORT(FILE *) ap_pfopen(ap_pool_t *a, const char *name, return fd; } -API_EXPORT(FILE *) ap_pfdopen(ap_pool_t *a, int fd, const char *mode) +API_EXPORT(FILE *) ap_pfdopen(ap_context_t *a, int fd, const char *mode) { FILE *f; int saved_errno; @@ -1283,7 +1306,7 @@ API_EXPORT(FILE *) ap_pfdopen(ap_pool_t *a, int fd, const char *mode) } -API_EXPORT(int) ap_pfclose(ap_pool_t *a, FILE *fd) +API_EXPORT(int) ap_pfclose(ap_context_t *a, FILE *fd) { int res; @@ -1298,12 +1321,13 @@ API_EXPORT(int) ap_pfclose(ap_pool_t *a, FILE *fd) * DIR * with cleanup */ -static void dir_cleanup(void *dv) +static ap_status_t dir_cleanup(void *dv) { closedir((DIR *) dv); + return APR_SUCCESS; } -API_EXPORT(DIR *) ap_popendir(ap_pool_t *p, const char *name) +API_EXPORT(DIR *) ap_popendir(ap_context_t *p, const char *name) { DIR *d; int save_errno; @@ -1321,7 +1345,7 @@ API_EXPORT(DIR *) ap_popendir(ap_pool_t *p, const char *name) return d; } -API_EXPORT(void) ap_pclosedir(ap_pool_t *p, DIR * d) +API_EXPORT(void) ap_pclosedir(ap_context_t *p, DIR * d) { ap_block_alarms(); ap_kill_cleanup(p, (void *) d, dir_cleanup); @@ -1335,23 +1359,24 @@ API_EXPORT(void) ap_pclosedir(ap_pool_t *p, DIR * d) * generic cleanup interface. */ -static void socket_cleanup(void *fdv) +static ap_status_t socket_cleanup(void *fdv) { closesocket((int) (long) fdv); + return APR_SUCCESS; } -API_EXPORT(void) ap_note_cleanups_for_socket(ap_pool_t *p, int fd) +API_EXPORT(void) ap_note_cleanups_for_socket(ap_context_t *p, int fd) { ap_register_cleanup(p, (void *) (long) fd, socket_cleanup, socket_cleanup); } -API_EXPORT(void) ap_kill_cleanups_for_socket(ap_pool_t *p, int sock) +API_EXPORT(void) ap_kill_cleanups_for_socket(ap_context_t *p, int sock) { ap_kill_cleanup(p, (void *) (long) sock, socket_cleanup); } -API_EXPORT(int) ap_psocket(ap_pool_t *p, int domain, int type, int protocol) +API_EXPORT(int) ap_psocket(ap_context_t *p, int domain, int type, int protocol) { int fd; @@ -1368,7 +1393,7 @@ API_EXPORT(int) ap_psocket(ap_pool_t *p, int domain, int type, int protocol) return fd; } -API_EXPORT(int) ap_pclosesocket(ap_pool_t *a, int sock) +API_EXPORT(int) ap_pclosesocket(ap_context_t *a, int sock) { int res; int save_errno; @@ -1394,12 +1419,13 @@ API_EXPORT(int) ap_pclosesocket(ap_pool_t *a, int sock) * regfree() doesn't clear it. So we don't allow it. */ -static void regex_cleanup(void *preg) +static ap_status_t regex_cleanup(void *preg) { regfree((regex_t *) preg); + return APR_SUCCESS; } -API_EXPORT(regex_t *) ap_pregcomp(ap_pool_t *p, const char *pattern, +API_EXPORT(regex_t *) ap_pregcomp(ap_context_t *p, const char *pattern, int cflags) { regex_t *preg = ap_palloc(p, sizeof(regex_t)); @@ -1408,20 +1434,21 @@ API_EXPORT(regex_t *) ap_pregcomp(ap_pool_t *p, const char *pattern, return NULL; } - ap_register_cleanup(p, (void *) preg, regex_cleanup, regex_cleanup); +/* ap_register_cleanup(p, (void *) preg, regex_cleanup, regex_cleanup);*/ + ap_register_cleanup(p, (void *) preg, ap_null_cleanup, ap_null_cleanup); return preg; } -API_EXPORT(void) ap_pregfree(ap_pool_t *p, regex_t * reg) +API_EXPORT(void) ap_pregfree(ap_context_t *p, regex_t * reg) { ap_block_alarms(); regfree(reg); ap_kill_cleanup(p, (void *) reg, regex_cleanup); ap_unblock_alarms(); } -#endif /* if 0 not really needed anymore. APR takes care of this. */ + /***************************************************************** * * More grotty system stuff... subprocesses. Frump. These don't use @@ -1458,8 +1485,8 @@ API_EXPORT(void) ap_note_subprocess(struct context_t *a, pid_t pid, #define BINMODE #endif -#if 0 -static pid_t spawn_child_core(ap_pool_t *p, + +static pid_t spawn_child_core(ap_context_t *p, int (*func) (void *, ap_child_info_t *), void *data,enum kill_conditions kill_how, int *pipe_in, int *pipe_out, int *pipe_err) @@ -1716,7 +1743,7 @@ static pid_t spawn_child_core(ap_pool_t *p, } -API_EXPORT(int) ap_spawn_child(ap_pool_t *p, +API_EXPORT(int) ap_spawn_child(ap_context_t *p, int (*func) (void *v, ap_child_info_t *c), void *data, enum kill_conditions kill_how, FILE **pipe_in, FILE **pipe_out, @@ -1773,7 +1800,7 @@ API_EXPORT(int) ap_spawn_child(ap_pool_t *p, ap_unblock_alarms(); return pid; } - +#if 0 API_EXPORT(int) ap_bspawn_child(ap_pool_t *p, int (*func) (void *v, ap_child_info_t *c), void *data, enum kill_conditions kill_how, diff --git a/misc/beos/start.c b/misc/beos/start.c index 1cc60689b..0f6409448 100644 --- a/misc/beos/start.c +++ b/misc/beos/start.c @@ -69,13 +69,13 @@ ap_status_t ap_create_context(ap_context_t *cont, void *data, ap_context_t **new ap_pool_t *pool; if (cont) { - pool = ap_make_sub_pool(cont->pool); + ap_context_t = ap_make_sub_pool(cont->pool); } else { - pool = ap_init_alloc();; + ap_context_t = ap_init_alloc();; } - if (pool == NULL) { + if (ap_context_t == NULL) { return APR_ENOPOOL; } diff --git a/misc/os2/start.c b/misc/os2/start.c index 00ad1f9a5..b99990880 100644 --- a/misc/os2/start.c +++ b/misc/os2/start.c @@ -66,13 +66,13 @@ ap_status_t ap_create_context(struct context_t *cont, void *data, ap_context_t * ap_pool_t *pool; if (cont) { - pool = ap_make_sub_pool(cont->pool); + ap_context_t = ap_make_sub_pool(cont->pool); } else { - pool = ap_init_alloc();; + ap_context_t = ap_init_alloc();; } - if (pool == NULL) { + if (ap_context_t == NULL) { return APR_ENOPOOL; } diff --git a/misc/unix/start.c b/misc/unix/start.c index b0ba0c20a..165e9e068 100644 --- a/misc/unix/start.c +++ b/misc/unix/start.c @@ -67,7 +67,7 @@ * Create a new context. * arg 1) The parent context. If this is NULL, the new context is a root * context. If it is non-NULL, the new context will inherit all - * of it's parent context's attributes, except the pool will be a + * of it's parent context's attributes, except the ap_context_t will be a * sub-pool. * arg 2) Any data to be assocaited with the context. If this is a * sub-context, and this value is NULL, the new context will diff --git a/misc/win32/start.c b/misc/win32/start.c index f0a6b0ece..2df24fe66 100644 --- a/misc/win32/start.c +++ b/misc/win32/start.c @@ -78,13 +78,13 @@ ap_status_t ap_create_context(ap_context_t *cont, void *data, ap_context_t **new ap_pool_t *pool; if (cont) { - pool = ap_make_sub_pool(cont->pool); + ap_context_t = ap_make_sub_pool(cont->pool); } else { - pool = ap_init_alloc();; + ap_context_t = ap_init_alloc();; } - if (pool == NULL) { + if (ap_context_t == NULL) { return APR_ENOPOOL; } diff --git a/shmem/shmem.c b/shmem/shmem.c index 7dc7768cf..735256e7c 100644 --- a/shmem/shmem.c +++ b/shmem/shmem.c @@ -112,7 +112,7 @@ ap_status_t ap_shm_realloc(struct shmem_t *shared, ap_size_t size, void **entity return APR_SUCCESS; } -ap_status_t apr_shm_free(struct shmem_t *shared, void *entity) +ap_status_t ap_shm_free(struct shmem_t *shared, void *entity) { mm_free(shared->mm, entity); return APR_SUCCESS; diff --git a/shmem/unix/mm/mm_alloc.c b/shmem/unix/mm/mm_alloc.c index 812a4d17b..90e851cad 100644 --- a/shmem/unix/mm/mm_alloc.c +++ b/shmem/unix/mm/mm_alloc.c @@ -77,7 +77,7 @@ MM *mm_create(size_t usize, const char *file) if ((core = mm_core_create(size, file)) == NULL) return NULL; - /* fill in the memory pool structure */ + /* fill in the memory ap_context_t structure */ mm = (MM *)core; mm->mp_size = size; mm->mp_offset = SIZEOF_mem_pool; @@ -115,7 +115,7 @@ void mm_destroy(MM *mm) } /* - * Lock a memory pool + * Lock a memory ap_context_t */ int mm_lock(MM *mm, mm_lock_mode mode) { @@ -125,7 +125,7 @@ int mm_lock(MM *mm, mm_lock_mode mode) } /* - * Unlock a memory pool + * Unlock a memory ap_context_t */ int mm_unlock(MM *mm) { diff --git a/shmem/unix/shmem.c b/shmem/unix/shmem.c index 8db258c3d..848e4fece 100644 --- a/shmem/unix/shmem.c +++ b/shmem/unix/shmem.c @@ -118,7 +118,7 @@ ap_status_t ap_shm_realloc(struct shmem_t *shared, ap_size_t size, void **entity return APR_SUCCESS; } -ap_status_t apr_shm_free(struct shmem_t *shared, void *entity) +ap_status_t ap_shm_free(struct shmem_t *shared, void *entity) { mm_free(shared->mm, entity); return APR_SUCCESS; diff --git a/test/ab_apr.c b/test/ab_apr.c index d3357b7fe..bb3796e4c 100644 --- a/test/ab_apr.c +++ b/test/ab_apr.c @@ -80,7 +80,7 @@ ** - Enhanced by Dean Gaudet <dgaudet@apache.org>, November 1997 ** - Cleaned up by Ralf S. Engelschall <rse@apache.org>, March 1998 ** - POST and verbosity by Kurt Sussman <kls@merlot.com>, August 1998 - ** - HTML table output added by David N. Welton <davidw@prosa.it>, January 1999 + ** - HTML ap_table_t output added by David N. Welton <davidw@prosa.it>, January 1999 ** */ @@ -810,7 +810,7 @@ static void usage(char *progname) fprintf(stderr, " -T content-type Content-type header for POSTing\n"); fprintf(stderr, " -v verbosity How much troubleshooting info to print\n"); fprintf(stderr, " -w Print out results in HTML tables\n"); - fprintf(stderr, " -x attributes String to insert as table attributes\n"); + fprintf(stderr, " -x attributes String to insert as ap_table_t attributes\n"); fprintf(stderr, " -y attributes String to insert as tr attributes\n"); fprintf(stderr, " -z attributes String to insert as td or th attributes\n"); fprintf(stderr, " -V Print version number and exit\n"); @@ -862,7 +862,7 @@ static int open_postfile(char *pfile) return errno; } - /* No need to perform stat here, the apr_open will do it for us. */ + /* No need to perform stat here, the ap_open will do it for us. */ ap_get_filesize(postfd, &postlen); postdata = (char *)malloc(postlen); @@ -886,7 +886,7 @@ int main(int argc, char **argv) { int c, r; - /* table defaults */ + /* ap_table_t defaults */ tablestring = ""; trstring = ""; tdstring = "bgcolor=white"; diff --git a/test/htdigest.c b/test/htdigest.c index 528aa5c81..5c94998d0 100644 --- a/test/htdigest.c +++ b/test/htdigest.c @@ -171,9 +171,9 @@ static void add_password(char *user, char *realm, ap_file_t *f) /* Do MD5 stuff */ sprintf(string, "%s:%s:%s", user, realm, pw); - apr_MD5Init(&context); - apr_MD5Update(&context, (unsigned char *) string, strlen(string)); - apr_MD5Final(digest, &context); + ap_MD5Init(&context); + ap_MD5Update(&context, (unsigned char *) string, strlen(string)); + ap_MD5Final(digest, &context); for (i = 0; i < 16; i++) ap_fprintf(f, "%02x", digest[i]); diff --git a/test/logresolve.c b/test/logresolve.c index c7ee9b8f7..8358dea7c 100644 --- a/test/logresolve.c +++ b/test/logresolve.c @@ -61,7 +61,7 @@ static void stats(FILE *output); #define MAXDNAME 256 #endif -/* number of buckets in cache hash table */ +/* number of buckets in cache hash ap_table_t */ #define BUCKETS 256 #if defined(NEED_STRDUP) diff --git a/test/testfile.c b/test/testfile.c index 8d3cfb0c4..abf3ee4d4 100644 --- a/test/testfile.c +++ b/test/testfile.c @@ -67,6 +67,7 @@ int testdirs(ap_context_t *); int main() { ap_context_t *context; + ap_context_t *cont2; ap_file_t *thefile = NULL; ap_status_t status = 0; ap_int32_t flag = APR_READ | APR_WRITE | APR_CREATE; @@ -80,6 +81,10 @@ int main() fprintf(stderr, "Couldn't allocate context."); exit(-1); } + if (ap_create_context(context, NULL, &cont2) != APR_SUCCESS) { + fprintf(stderr, "Couldn't allocate context."); + exit(-1); + } fprintf(stdout, "Testing file functions.\n"); diff --git a/threadproc/unix/proc.c b/threadproc/unix/proc.c index 3022350e5..3fdf9a9f3 100644 --- a/threadproc/unix/proc.c +++ b/threadproc/unix/proc.c @@ -206,7 +206,7 @@ ap_status_t ap_fork(ap_context_t *cont, struct proc_t **proc) * arg 2) The program to run * arg 3) the arguments to pass to the new program. The first one should * be the program name. - * arg 4) The new environment table for the new process. This should be a + * arg 4) The new environment ap_table_t for the new process. This should be a * list of NULL-terminated strings. * arg 5) the procattr we should use to determine how to create the new * process diff --git a/threadproc/unix/threadproc.h b/threadproc/unix/threadproc.h index fc9755011..81c9f67a1 100644 --- a/threadproc/unix/threadproc.h +++ b/threadproc/unix/threadproc.h @@ -96,7 +96,7 @@ struct proc_t { struct procattr_t *attr; }; -/*This will move to apr_threadproc.h in time, but I need to figure it out +/*This will move to ap_threadproc.h in time, but I need to figure it out * on windows first. :) */ ap_status_t ap_detach(ap_context_t *, struct proc_t **); |