diff options
-rw-r--r-- | include/apr_thread_proc.h | 2 | ||||
-rw-r--r-- | include/apr_user.h | 12 | ||||
-rw-r--r-- | include/arch/win32/misc.h | 177 | ||||
-rw-r--r-- | memory/unix/apr_sms_threads.c | 6 | ||||
-rw-r--r-- | test/aprtest.h | 90 | ||||
-rw-r--r-- | test/server.c | 180 | ||||
-rw-r--r-- | test/testlock.c | 8 | ||||
-rw-r--r-- | test/testmmap.c | 6 | ||||
-rw-r--r-- | test/testuser.c | 63 | ||||
-rw-r--r-- | threadproc/beos/threadcancel.c | 88 | ||||
-rw-r--r-- | threadproc/os2/threadcancel.c | 85 | ||||
-rw-r--r-- | threadproc/win32/threadcancel.c | 86 | ||||
-rw-r--r-- | user/unix/userinfo.c | 15 | ||||
-rw-r--r-- | user/win32/userinfo.c | 33 |
14 files changed, 162 insertions, 689 deletions
diff --git a/include/apr_thread_proc.h b/include/apr_thread_proc.h index 8b33d4032..b0d6b1a11 100644 --- a/include/apr_thread_proc.h +++ b/include/apr_thread_proc.h @@ -587,7 +587,7 @@ APR_DECLARE(void) apr_pool_note_subprocess(apr_pool_t *a, apr_proc_t *pid, #if APR_HAS_THREADS -#if !defined(OS2) && APR_HAVE_SIGWAIT +#if APR_HAVE_SIGWAIT && !defined(OS2) /** * Setup the process for a single thread to be used for all signal handling. diff --git a/include/apr_user.h b/include/apr_user.h index ac781bd6d..3c70da037 100644 --- a/include/apr_user.h +++ b/include/apr_user.h @@ -90,18 +90,6 @@ typedef gid_t apr_gid_t; #if APR_HAS_USER /*** - * Get the userid (and groupid) of the calling process - * @param userid Returns the user id - * @param groupid Returns the user's group id - * @param p The pool from which to allocate working space - * @tip This function is available only if APR_HAS_USER is defined. - * @deffunc apr_status_t apr_current_userid(apr_uid_t *userid, apr_gid_t *groupid, apr_pool_t *p) - */ -APR_DECLARE(apr_status_t) apr_current_userid(apr_uid_t *userid, - apr_gid_t *groupid, - apr_pool_t *p); - -/*** * Get the user name for a specified userid * @param username Pointer to new string containing user name (on output) * @param userid The userid diff --git a/include/arch/win32/misc.h b/include/arch/win32/misc.h deleted file mode 100644 index e896f1224..000000000 --- a/include/arch/win32/misc.h +++ /dev/null @@ -1,177 +0,0 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000-2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -#ifndef MISC_H -#define MISC_H - -#include "apr.h" -#include "apr_portable.h" -#include "apr_private.h" -#include "apr_general.h" -#include "apr_pools.h" -#include "apr_getopt.h" -#include "apr_thread_proc.h" -#include "apr_file_io.h" -#include "apr_errno.h" -#include "apr_getopt.h" - -#if APR_HAVE_STDIO_H -#include <stdio.h> -#endif -#if APR_HAVE_SIGNAL_H -#include <signal.h> -#endif -#if APR_HAVE_PTHREAD_H -#include <pthread.h> -#endif - -/* ### create APR_HAVE_* macros for these? */ -#if APR_HAVE_STDLIB_H -#include <stdlib.h> -#endif -#if APR_HAVE_STRING_H -#include <string.h> -#endif - -#ifdef BEOS -#include <kernel/OS.h> -#endif - -struct apr_other_child_rec_t { - apr_pool_t *p; - struct apr_other_child_rec_t *next; - int id; /* This is either a pid or tid depending on the platform */ - void (*maintenance) (int, void *, int); - void *data; - apr_os_file_t write_fd; -}; - -#ifdef WIN32 -#define WSAHighByte 2 -#define WSALowByte 0 -/* Platform specific designation of run time os version. - * Gaps allow for specific service pack levels that - * export new kernel or winsock functions or behavior. - */ -typedef enum { - APR_WIN_95 = 0, - APR_WIN_98 = 4, - APR_WIN_NT = 8, - APR_WIN_NT_4 = 12, - APR_WIN_NT_4_SP2 = 14, - APR_WIN_NT_4_SP3 = 15, - APR_WIN_NT_4_SP4 = 16, - APR_WIN_NT_4_SP6 = 18, - APR_WIN_2000 = 24 -} apr_oslevel_e; - - -typedef enum { - DLL_WINBASEAPI = 0, // kernel32 From WinBase.h - DLL_WINADVAPI = 1, // advapi32 From WinBase.h - DLL_WINSOCKAPI = 2, // mswsock From WinSock.h - DLL_WINSOCK2API = 3, // ws2_32 From WinSock2.h - DLL_defined = 4 // must define as last idx_ + 1 -} apr_dlltoken_e; - -FARPROC apr_load_dll_func(apr_dlltoken_e fnLib, char *fnName, int ordinal); - -/* The apr_load_dll_func call WILL fault if the function cannot be loaded */ - -#define APR_DECLARE_LATE_DLL_FUNC(lib, rettype, calltype, fn, ord, args, names) \ - typedef rettype (calltype *apr_winapi_fpt_##fn) args; \ - static apr_winapi_fpt_##fn apr_winapi_pfn_##fn = NULL; \ - __inline rettype apr_winapi_##fn args \ - { if (!apr_winapi_pfn_##fn) \ - apr_winapi_pfn_##fn = (apr_winapi_fpt_##fn) \ - apr_load_dll_func(lib, #fn, ord); \ - return (*(apr_winapi_pfn_##fn)) names; }; \ - -/* Provide late bound declarations of every API function missing from - * one or more supported releases of the Win32 API - * - * lib is the enumerated token from apr_dlltoken_e, and must correspond - * to the string table entry in start.c used by the apr_load_dll_func(). - * Token names (attempt to) follow Windows.h declarations prefixed by DLL_ - * in order to facilitate comparison. Use the exact declaration syntax - * and names from Windows.h to prevent ambigutity and bugs. - * - * rettype and calltype follow the original declaration in Windows.h - * fn is the true function name - beware Ansi/Unicode #defined macros - * ord is the ordinal within the library, use 0 if it varies between versions - * args is the parameter list following the original declaration, in parens - * names is the parameter list sans data types, enclosed in parens - * - * #undef/re#define the Ansi/Unicode generic name to abate confusion - * In the case of non-text functions, simply #define the original name - */ - -APR_DECLARE_LATE_DLL_FUNC(DLL_WINBASEAPI, BOOL, WINAPI, GetFileAttributesExA, 0, ( - IN LPCSTR lpFileName, - IN GET_FILEEX_INFO_LEVELS fInfoLevelId, - OUT LPVOID lpFileInformation), - (lpFileName, fInfoLevelId, lpFileInformation)); -#undef GetFileAttributesEx -#define GetFileAttributesEx apr_winapi_GetFileAttributesExA - -APR_DECLARE_LATE_DLL_FUNC(DLL_WINBASEAPI, BOOL, WINAPI, CancelIo, 0, ( - IN HANDLE hFile), - (hFile)); -#define CancelIo apr_winapi_CancelIo - -apr_status_t apr_get_oslevel(struct apr_pool_t *, apr_oslevel_e *); -#endif /* WIN32 */ - -#endif /* ! MISC_H */ - diff --git a/memory/unix/apr_sms_threads.c b/memory/unix/apr_sms_threads.c index e4ede123f..f701bbcde 100644 --- a/memory/unix/apr_sms_threads.c +++ b/memory/unix/apr_sms_threads.c @@ -165,7 +165,7 @@ static void *apr_sms_threads_malloc(apr_sms_t *sms, /* If the thread wasn't registered before, we will segfault */ thread_node = SMS_THREADS_T(sms)->hashtable[hash]; - while (!apr_os_thread_equal(thread_node->thread, thread)) + while (thread_node->thread != thread) thread_node = thread_node->next; node = thread_node->used_sentinel.prev; @@ -309,7 +309,7 @@ static apr_status_t apr_sms_threads_free(apr_sms_t *sms, void *mem) hash = THREAD_HASH(thread); thread_node = SMS_THREADS_T(sms)->hashtable[hash]; - while (!apr_os_thread_equal(thread_node->thread, thread)) + while (thread_node->thread != thread) thread_node = thread_node->next; node->avail_size += node->first_avail - @@ -639,7 +639,7 @@ static apr_status_t apr_sms_threads_thread_unregister(apr_sms_t *sms, apr_lock_acquire(SMS_THREADS_T(sms)->lock); thread_node = SMS_THREADS_T(sms)->hashtable[hash]; - while (!apr_os_thread_equal(thread_node->thread, thread)) + while (thread_node->thread != thread) thread_node = thread_node->next; if ((*thread_node->ref = thread_node->next) != NULL) diff --git a/test/aprtest.h b/test/aprtest.h deleted file mode 100644 index 5c26e43e7..000000000 --- a/test/aprtest.h +++ /dev/null @@ -1,90 +0,0 @@ - * ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000-2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -#include "apr_errno.h" -#include "apr_general.h" -#include "apr_strings.h" - -#ifndef APR_TEST_PREFIX -#define APR_TEST_PREFIX "" -#endif - -#define APR_TEST_BEGIN(rv, desc, op) \ - fprintf(stdout, "%s%.*s ", APR_TEST_PREFIX desc, \ - strlen(desc) < 37 ? 40 - strlen(desc) : 3, \ - "........................................"); \ - APR_TEST_MORE(rv, op) - -#define APR_TEST_MORE(rv, op) \ - if ((rv = (op)) != APR_SUCCESS) { \ - char msgbuf[256]; \ - fprintf (stdout, "Failed\n"); \ - fprintf (stderr, "Error (%d): %s\n%s", rv, #op, \ - apr_strerror(stat, msgbuf, sizeof(msgbuf))); \ - exit(-1); } - -#define APR_TEST_END(rv, op) \ - APR_TEST_MORE(rv, op) \ - fprintf(stdout, "OK\n"); - -#define APR_TEST_SUCCESS(rv, desc, op) \ - APR_TEST_BEGIN(rv, desc, op) \ - fprintf(stdout, "OK\n"); - -#define APR_TEST_INITIALIZE(rv, pool) \ - APR_TEST_SUCCESS(rv, "Initializing", apr_initialize()); \ - atexit(apr_terminate); \ - APR_TEST_SUCCESS(rv, "Creating context", \ - apr_pool_create(&pool, NULL)); - diff --git a/test/server.c b/test/server.c index 539da10ff..4c5087b8b 100644 --- a/test/server.c +++ b/test/server.c @@ -52,11 +52,10 @@ * <http://www.apache.org/>. */ -#define APR_TEST_PREFIX "server: " - -#include "aprtest.h" #include <stdlib.h> #include "apr_network_io.h" +#include "apr_errno.h" +#include "apr_general.h" #include "apr_getopt.h" #define STRLEN 15 @@ -64,11 +63,10 @@ int main(int argc, const char * const argv[]) { apr_pool_t *context; - apr_status_t rv; apr_socket_t *sock; apr_socket_t *sock2; apr_size_t length; - apr_int32_t pollres; + apr_int32_t rv; apr_pollfd_t *sdset; char datasend[STRLEN]; char datarecv[STRLEN] = "Recv data test"; @@ -78,15 +76,31 @@ int main(int argc, const char * const argv[]) apr_sockaddr_t *localsa = NULL, *remotesa; apr_status_t stat; int family = APR_UNSPEC; + char buf[128]; apr_getopt_t *opt; const char *optarg; char optchar; - APR_TEST_INITIALIZE(rv, context); + fprintf(stdout, "Initializing........."); + if (apr_initialize() != APR_SUCCESS) { + fprintf(stderr, "Something went wrong\n"); + exit(-1); + } + fprintf(stdout, "OK\n"); + atexit(apr_terminate); + + fprintf(stdout, "Creating context......."); + if (apr_pool_create(&context, NULL) != APR_SUCCESS) { + fprintf(stderr, "Could not create a context\n"); + exit(-1); + } + fprintf(stdout, "OK\n"); + + if (apr_getopt_init(&opt, context, argc, argv)) { + fprintf(stderr, "failed to initialize opts\n"); + exit(-1); + } - APR_TEST_SUCCESS(rv, "Preparing getopt", - apr_getopt_init(&opt, context, argc, argv)) - while ((stat = apr_getopt(opt, "i:", &optchar, &optarg)) == APR_SUCCESS) { switch(optchar) { case 'i': @@ -106,51 +120,88 @@ int main(int argc, const char * const argv[]) * socket we need. We'll use the returned sockaddr later when * we bind. */ - APR_TEST_SUCCESS(rv, "Preparing sockaddr", - apr_sockaddr_info_get(&localsa, bind_to_ipaddr, APR_UNSPEC, 8021, 0, context)) + stat = apr_sockaddr_info_get(&localsa, bind_to_ipaddr, APR_UNSPEC, 8021, 0, + context); + if (stat != APR_SUCCESS) { + fprintf(stderr, + "Couldn't build the socket address correctly: %s\n", + apr_strerror(stat, buf, sizeof buf)); + exit(-1); + } family = localsa->sa.sin.sin_family; } - APR_TEST_SUCCESS(rv, "Creating new socket", - apr_socket_create(&sock, family, SOCK_STREAM, context)) + fprintf(stdout, "\tServer: Creating new socket......."); + if (apr_socket_create(&sock, family, SOCK_STREAM, context) != APR_SUCCESS) { + fprintf(stderr, "Couldn't create socket\n"); + exit(-1); + } + fprintf(stdout, "OK\n"); - APR_TEST_SUCCESS(rv, "Setting option APR_SO_NONBLOCK", - apr_setsocketopt(sock, APR_SO_NONBLOCK, 1)) + fprintf(stdout, "\tServer: Setting socket option NONBLOCK......."); + if (apr_setsocketopt(sock, APR_SO_NONBLOCK, 1) != APR_SUCCESS) { + apr_socket_close(sock); + fprintf(stderr, "Couldn't set socket option\n"); + exit(-1); + } + fprintf(stdout, "OK\n"); - APR_TEST_SUCCESS(rv, "Setting option APR_SO_REUSEADDR", - apr_setsocketopt(sock, APR_SO_REUSEADDR, 1)) + fprintf(stdout, "\tServer: Setting socket option REUSEADDR......."); + if (apr_setsocketopt(sock, APR_SO_REUSEADDR, 1) != APR_SUCCESS) { + apr_socket_close(sock); + fprintf(stderr, "Couldn't set socket option\n"); + exit(-1); + } + fprintf(stdout, "OK\n"); if (!localsa) { apr_socket_addr_get(&localsa, APR_LOCAL, sock); apr_sockaddr_port_set(localsa, 8021); } - APR_TEST_SUCCESS(rv, "Binding socket to port", - apr_bind(sock, localsa)) - - APR_TEST_SUCCESS(rv, "Listening to socket", - apr_listen(sock, 5)) - - APR_TEST_BEGIN(rv, "Setting up for polling", - apr_poll_setup(&sdset, 1, context)) - APR_TEST_END(rv, - apr_poll_socket_add(sdset, sock, APR_POLLIN)) + fprintf(stdout, "\tServer: Binding socket to port......."); + if ((stat = apr_bind(sock, localsa)) != APR_SUCCESS) { + apr_socket_close(sock); + fprintf(stderr, "Could not bind: %s\n", + apr_strerror(stat, buf, sizeof buf)); + exit(-1); + } + fprintf(stdout, "OK\n"); - pollres = 1; - APR_TEST_BEGIN(rv, "Polling for socket", - apr_poll(sdset, &pollres, -1)) + fprintf(stdout, "\tServer: Listening to socket......."); + if (apr_listen(sock, 5) != APR_SUCCESS) { + apr_socket_close(sock); + fprintf(stderr, "Could not listen\n"); + exit(-1); + } + fprintf(stdout, "OK\n"); - if (pollres == 0) { - fprintf(stdout, "Failed\n"); + fprintf(stdout, "\tServer: Setting up socket for polling......."); + apr_poll_setup(&sdset, 1, context); + apr_poll_socket_add(sdset, sock, APR_POLLIN); + fprintf(stdout, "OK\n"); + + fprintf(stdout, "\tServer: Beginning to poll for socket......."); + rv = 1; + if (apr_poll(sdset, &rv, -1) != APR_SUCCESS) { + apr_socket_close(sock); + fprintf(stderr, "Select caused an error\n"); + exit(-1); + } + else if (rv == 0) { apr_socket_close(sock); - fprintf(stderr, "Error: Unrecognized poll result, " - "expected 1, received %d\n", pollres); + fprintf(stderr, "I should not return until rv == 1\n"); exit(-1); } fprintf(stdout, "OK\n"); - APR_TEST_SUCCESS(rv, "Accepting a connection", - apr_accept(&sock2, sock, context)) + fprintf(stdout, "\tServer: Accepting a connection......."); + if (apr_accept(&sock2, sock, context) != APR_SUCCESS) { + apr_socket_close(sock); + fprintf(stderr, "Could not accept connection.\n"); + exit(-1); + } + fprintf(stdout, "OK\n"); apr_socket_addr_get(&remotesa, APR_REMOTE, sock2); apr_sockaddr_ip_get(&remote_ipaddr, remotesa); @@ -158,37 +209,58 @@ int main(int argc, const char * const argv[]) apr_socket_addr_get(&localsa, APR_LOCAL, sock2); apr_sockaddr_ip_get(&local_ipaddr, localsa); apr_sockaddr_port_get(&local_port, localsa); - fprintf(stdout, "Server socket: %s:%u -> %s:%u\n", local_ipaddr, - local_port, remote_ipaddr, remote_port); + fprintf(stdout, "\tServer socket: %s:%u -> %s:%u\n", local_ipaddr, local_port, remote_ipaddr, remote_port); length = STRLEN; - APR_TEST_BEGIN(rv, "Receiving data from socket", - apr_recv(sock2, datasend, &length)) - + fprintf(stdout, "\tServer: Trying to recv data from socket......."); + if (apr_recv(sock2, datasend, &length) != APR_SUCCESS) { + apr_socket_close(sock); + apr_socket_close(sock2); + fprintf(stderr, "Problem recving data\n"); + exit(-1); + } if (strcmp(datasend, "Send data test")) { - fprintf(stdout, "Failed\n"); apr_socket_close(sock); apr_socket_close(sock2); - fprintf(stderr, "Error: Unrecognized response;\n" - "Expected: \"Send data test\"\n" - "Received: \"%s\"\n", datarecv); + fprintf(stderr, "I did not receive the correct data %s\n", datarecv); exit(-1); } fprintf(stdout, "OK\n"); length = STRLEN; - APR_TEST_SUCCESS(rv, "Sending data over socket", - apr_send(sock2, datarecv, &length)) + fprintf(stdout, "\tServer: Sending data over socket......."); + if (apr_send(sock2, datarecv, &length) != APR_SUCCESS) { + apr_socket_close(sock); + apr_socket_close(sock2); + fprintf(stderr, "Problem sending data\n"); + exit(-1); + } + fprintf(stdout, "OK\n"); - APR_TEST_SUCCESS(rv, "Shutting down accepted socket", - apr_shutdown(sock2, APR_SHUTDOWN_READ)) + fprintf(stdout, "\tServer: Shutting down accepted socket......."); + if (apr_shutdown(sock2, APR_SHUTDOWN_READ) != APR_SUCCESS) { + apr_socket_close(sock); + apr_socket_close(sock2); + fprintf(stderr, "Problem shutting down\n"); + exit(-1); + } + fprintf(stdout, "OK\n"); - APR_TEST_SUCCESS(rv, "Closing duplicate socket", - apr_socket_close(sock2)) + fprintf(stdout, "\tServer: closing duplicate socket......."); + if (apr_socket_close(sock2) != APR_SUCCESS) { + apr_socket_close(sock); + fprintf(stderr, "Problem closing down\n"); + exit(-1); + } + fprintf(stdout, "OK\n"); - APR_TEST_SUCCESS(rv, "Closing original socket", - apr_socket_close(sock)) + fprintf(stdout, "\tServer: closing original socket......."); + if (apr_socket_close(sock) != APR_SUCCESS) { + fprintf(stderr, "Problem closing down\n"); + exit(-1); + } + fprintf(stdout, "OK\n"); - return 0; + return 1; } diff --git a/test/testlock.c b/test/testlock.c index 229b4de01..af675ae48 100644 --- a/test/testlock.c +++ b/test/testlock.c @@ -73,8 +73,8 @@ int main(void) #define MAX_ITER 40000 -void * APR_THREAD_FUNC thread_rw_func(apr_thread_t *thd, void *data); -void * APR_THREAD_FUNC thread_function(apr_thread_t *thd, void *data); +void * APR_THREAD_FUNC thread_rw_func(void *data); +void * APR_THREAD_FUNC thread_function(void *data); apr_status_t test_exclusive(void); apr_status_t test_rw(void); apr_status_t test_multiple_locking(void); @@ -85,7 +85,7 @@ apr_lock_t *thread_rw_lock, *thread_lock; apr_pool_t *pool; int i = 0, x = 0; -void * APR_THREAD_FUNC thread_rw_func(apr_thread_t *thd, void *data) +void * APR_THREAD_FUNC thread_rw_func(void *data) { int exitLoop = 1; @@ -110,7 +110,7 @@ void * APR_THREAD_FUNC thread_rw_func(apr_thread_t *thd, void *data) return NULL; } -void * APR_THREAD_FUNC thread_function(apr_thread_t *thd, void *data) +void * APR_THREAD_FUNC thread_function(void *data) { int exitLoop = 1; diff --git a/test/testmmap.c b/test/testmmap.c index 0fe59b90e..eaf53e89a 100644 --- a/test/testmmap.c +++ b/test/testmmap.c @@ -57,7 +57,6 @@ #include "apr_general.h" #include "apr_lib.h" #include "apr_file_io.h" -#include "apr_strings.h" #if APR_HAVE_UNISTD_H #include <unistd.h> #endif @@ -99,8 +98,9 @@ int main(void) } fprintf(stdout,"OK\n"); - apr_filepath_get(&file1, context); - file1 = apr_pstrcat(context,file1,"/testmmap.c",NULL); + file1 = (char*) apr_palloc(context, sizeof(char) * PATH_LEN); + getcwd(file1, PATH_LEN); + strncat(file1,"/testmmap.c",11); fprintf(stdout, "Opening file........................"); rv = apr_file_open(&thefile, file1, flag, APR_UREAD | APR_GREAD, context); diff --git a/test/testuser.c b/test/testuser.c index 9c7b3e43a..4de8ff9ed 100644 --- a/test/testuser.c +++ b/test/testuser.c @@ -72,12 +72,20 @@ int main(int argc, char *argv[]) apr_pool_t *p; apr_status_t rv; char msgbuf[80]; - char *groupname; - char *username; + const char *username; char *homedir; apr_uid_t userid; apr_gid_t groupid; + if (argc != 2) { + fprintf(stderr, + "usage: %s username\n", + argv[0]); + exit(-1); + } + + username = argv[1]; + if (apr_initialize() != APR_SUCCESS) { fprintf(stderr, "Something went wrong\n"); exit(-1); @@ -89,51 +97,30 @@ int main(int argc, char *argv[]) exit(-1); } - if (argc != 2) { - fprintf(stderr, - "optional: %s username\n", - argv[0]); - if ((rv = apr_current_userid(&userid, &groupid, p)) != APR_SUCCESS) { - fprintf(stderr, "apr_current_userid failed: %s\n", - apr_strerror(rv, msgbuf, sizeof(msgbuf))); - exit(-1); - } - apr_get_username(&username, userid, p); - if (rv != APR_SUCCESS) { - fprintf(stderr, "apr_get_username(,,) failed: %s\n", - apr_strerror(rv, msgbuf, sizeof(msgbuf))); - exit(-1); - } + rv = apr_get_home_directory(&homedir, username, p); + if (rv != APR_SUCCESS) { + fprintf(stderr, "apr_get_home_directory(,%s,) failed: %s\n", + username, + apr_strerror(rv, msgbuf, sizeof(msgbuf))); + exit(-1); } else { - username = argv[1]; - - rv = apr_get_userid(&userid, &groupid, username, p); - if (rv != APR_SUCCESS) { - fprintf(stderr, "apr_get_userid(,,%s,) failed: %s\n", - username, - apr_strerror(rv, msgbuf, sizeof(msgbuf))); - exit(-1); - } + printf("home directory for %s: `%s'\n", + username, homedir); } - rv = apr_get_groupname(&groupname, groupid, p); - if (rv != APR_SUCCESS) - groupname = "(none)"; - - printf("user/group ids for %s: %d/%d\n", - username, - (int)userid, (int)groupid); - - rv = apr_get_home_directory(&homedir, username, p); + rv = apr_get_userid(&userid, &groupid, username, p); if (rv != APR_SUCCESS) { - fprintf(stderr, "apr_get_home_directory(,%s,) failed: %s\n", + fprintf(stderr, "apr_get_userid(,,%s,) failed: %s\n", username, apr_strerror(rv, msgbuf, sizeof(msgbuf))); exit(-1); } - printf("home directory for %s (member of %s) is:\n`%s'\n", - username, groupname, homedir); + else { + printf("user/group ids for %s: %d/%d\n", + username, + (int)userid, (int)groupid); + } return 1; } diff --git a/threadproc/beos/threadcancel.c b/threadproc/beos/threadcancel.c deleted file mode 100644 index 94a7e9407..000000000 --- a/threadproc/beos/threadcancel.c +++ /dev/null @@ -1,88 +0,0 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -#include "threadproc.h" - - -ap_status_t ap_cancel_thread(ap_thread_t *thd) -{ - if (kill_thread(thd->td) == 0) { - return APR_SUCCESS; - } - else { - return errno; - } -} - - -ap_status_t ap_setcanceltype(ap_int32_t type, ap_pool_t *cont) -{ -/* if (pthread_setcanceltype(type, NULL) == 0) {*/ - return APR_SUCCESS; -/* } - else { - return APR_FAILURE; - }*/ -} - -ap_status_t ap_setcancelstate(ap_int32_t type, ap_pool_t *cont) -{ -/* if (pthread_setcanceltype(type, NULL) == 0) {*/ - return APR_SUCCESS; -/* } - else { - return APR_FAILURE; - }*/ -} - diff --git a/threadproc/os2/threadcancel.c b/threadproc/os2/threadcancel.c deleted file mode 100644 index ca7a18753..000000000 --- a/threadproc/os2/threadcancel.c +++ /dev/null @@ -1,85 +0,0 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -#include "threadproc.h" -#include "apr_thread_proc.h" -#include "apr_general.h" -#include "fileio.h" - -ap_status_t ap_cancel_thread(ap_thread_t *thd) -{ - return APR_OS2_STATUS(DosKillThread(thd->tid)); -} - - - -ap_status_t ap_setcanceltype(ap_int32_t type, ap_pool_t *cont) -{ - ULONG rc, nesting; - - if (type == APR_CANCEL_DEFER) - rc = DosEnterMustComplete(&nesting); - else - rc = DosExitMustComplete(&nesting); - - return APR_OS2_STATUS(rc); -} - - - -ap_status_t ap_setcancelstate(ap_int32_t type, ap_pool_t *cont) -{ -/* There's no way to ignore thread kills altogether in OS/2 (that I know of) */ - return APR_ENOTIMPL; -} diff --git a/threadproc/win32/threadcancel.c b/threadproc/win32/threadcancel.c deleted file mode 100644 index 3a509202b..000000000 --- a/threadproc/win32/threadcancel.c +++ /dev/null @@ -1,86 +0,0 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -#include "threadproc.h" -#include "apr_thread_proc.h" -#include "apr_general.h" - - -ap_status_t ap_cancel_thread(ap_thread_t *thd) -{ - if (TerminateThread(thd->td, APR_SUCCESS) == 0) { - return APR_EEXIST; - } - else { - return APR_SUCCESS; - } -} - -/* Not sure of the best way to do this just yet. -ap_status_t ap_setcanceltype(ap_int32_t type, ap_pool_t *cont) -{ - -} - -ap_status_t ap_setcancelstate(ap_int32_t type, ap_pool_t *cont) -{ - ap_status_t stat; - if ((stat = pthread_setcanceltype(type, NULL)) == 0) { - return APR_SUCCESS; - } - else { - return stat; - } -} -*/ diff --git a/user/unix/userinfo.c b/user/unix/userinfo.c index 27445e4ee..4dade21a0 100644 --- a/user/unix/userinfo.c +++ b/user/unix/userinfo.c @@ -111,21 +111,6 @@ APR_DECLARE(apr_status_t) apr_get_home_directory(char **dirname, return APR_SUCCESS; } - - -APR_DECLARE(apr_status_t) apr_current_userid(apr_uid_t *uid, - apr_gid_t *gid, - apr_pool_t *p) -{ - *uid = getuid(); - *gid = getgid(); - - return APR_SUCCESS; -} - - - - APR_DECLARE(apr_status_t) apr_get_userid(apr_uid_t *uid, apr_gid_t *gid, const char *username, apr_pool_t *p) { diff --git a/user/win32/userinfo.c b/user/win32/userinfo.c index 66f9abb4a..8636d174a 100644 --- a/user/win32/userinfo.c +++ b/user/win32/userinfo.c @@ -189,39 +189,6 @@ APR_DECLARE(apr_status_t) apr_get_home_directory(char **dirname, const char *use return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_current_userid(apr_uid_t *uid, - apr_gid_t *gid, - apr_pool_t *p) -{ - HANDLE threadtok; - DWORD needed; - TOKEN_USER *usr; - TOKEN_PRIMARY_GROUP *grp; - - if(!OpenProcessToken(GetCurrentProcess(), STANDARD_RIGHTS_READ | READ_CONTROL | TOKEN_QUERY, &threadtok)) { - return apr_get_os_error(); - } - - *uid = NULL; - if (!GetTokenInformation(threadtok, TokenUser, NULL, 0, &needed) - && (GetLastError() == ERROR_INSUFFICIENT_BUFFER) - && (usr = apr_palloc(p, needed)) - && GetTokenInformation(threadtok, TokenUser, usr, needed, &needed)) - *uid = usr->User.Sid; - else - return apr_get_os_error(); - - if (!GetTokenInformation(threadtok, TokenPrimaryGroup, NULL, 0, &needed) - && (GetLastError() == ERROR_INSUFFICIENT_BUFFER) - && (grp = apr_palloc(p, needed)) - && GetTokenInformation(threadtok, TokenPrimaryGroup, grp, needed, &needed)) - *gid = grp->PrimaryGroup; - else - return apr_get_os_error(); - - return APR_SUCCESS; -} - APR_DECLARE(apr_status_t) apr_get_userid(apr_uid_t *uid, apr_gid_t *gid, const char *username, apr_pool_t *p) { |