Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages

apr_thread_proc.h

Go to the documentation of this file.
00001 /* ==================================================================== 00002 * The Apache Software License, Version 1.1 00003 * 00004 * Copyright (c) 2000-2003 The Apache Software Foundation. All rights 00005 * reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 00011 * 1. Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * 00014 * 2. Redistributions in binary form must reproduce the above copyright 00015 * notice, this list of conditions and the following disclaimer in 00016 * the documentation and/or other materials provided with the 00017 * distribution. 00018 * 00019 * 3. The end-user documentation included with the redistribution, 00020 * if any, must include the following acknowledgment: 00021 * "This product includes software developed by the 00022 * Apache Software Foundation (http://www.apache.org/)." 00023 * Alternately, this acknowledgment may appear in the software itself, 00024 * if and wherever such third-party acknowledgments normally appear. 00025 * 00026 * 4. The names "Apache" and "Apache Software Foundation" must 00027 * not be used to endorse or promote products derived from this 00028 * software without prior written permission. For written 00029 * permission, please contact apache@apache.org. 00030 * 00031 * 5. Products derived from this software may not be called "Apache", 00032 * nor may "Apache" appear in their name, without prior written 00033 * permission of the Apache Software Foundation. 00034 * 00035 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 00036 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00037 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00038 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR 00039 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00040 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00041 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 00042 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00043 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00044 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 00045 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00046 * SUCH DAMAGE. 00047 * ==================================================================== 00048 * 00049 * This software consists of voluntary contributions made by many 00050 * individuals on behalf of the Apache Software Foundation. For more 00051 * information on the Apache Software Foundation, please see 00052 * <http://www.apache.org/>. 00053 */ 00054 00055 #ifndef APR_THREAD_PROC_H 00056 #define APR_THREAD_PROC_H 00057 00063 #include "apr.h" 00064 #include "apr_file_io.h" 00065 #include "apr_pools.h" 00066 #include "apr_errno.h" 00067 00068 #if APR_HAVE_STRUCT_RLIMIT 00069 #include <sys/time.h> 00070 #include <sys/resource.h> 00071 #endif 00072 00073 #ifdef __cplusplus 00074 extern "C" { 00075 #endif /* __cplusplus */ 00076 00083 typedef enum { 00084 APR_SHELLCMD, 00085 APR_PROGRAM, 00086 APR_PROGRAM_ENV, 00087 APR_PROGRAM_PATH 00088 } apr_cmdtype_e; 00089 00090 typedef enum { 00091 APR_WAIT, 00092 APR_NOWAIT 00093 } apr_wait_how_e; 00094 00095 /* I am specifically calling out the values so that the macros below make 00096 * more sense. Yes, I know I don't need to, but I am hoping this makes what 00097 * I am doing more clear. If you want to add more reasons to exit, continue 00098 * to use bitmasks. 00099 */ 00100 typedef enum { 00101 APR_PROC_EXIT = 1, 00102 APR_PROC_SIGNAL = 2, 00103 APR_PROC_SIGNAL_CORE = 4 00104 } apr_exit_why_e; 00105 00107 #define APR_PROC_CHECK_EXIT(x) (x & APR_PROC_EXIT) 00108 00109 #define APR_PROC_CHECK_SIGNALED(x) (x & APR_PROC_SIGNAL) 00110 00111 #define APR_PROC_CHECK_CORE_DUMP(x) (x & APR_PROC_SIGNAL_CORE) 00112 00114 #define APR_NO_PIPE 0 00115 00117 #define APR_FULL_BLOCK 1 00118 00119 #define APR_FULL_NONBLOCK 2 00120 00121 #define APR_PARENT_BLOCK 3 00122 00123 #define APR_CHILD_BLOCK 4 00124 00126 #define APR_LIMIT_CPU 0 00127 00128 #define APR_LIMIT_MEM 1 00129 00130 #define APR_LIMIT_NPROC 2 00131 00132 #define APR_LIMIT_NOFILE 3 00133 00138 #define APR_OC_REASON_DEATH 0 00140 #define APR_OC_REASON_UNWRITABLE 1 00141 #define APR_OC_REASON_RESTART 2 00145 #define APR_OC_REASON_UNREGISTER 3 00148 #define APR_OC_REASON_LOST 4 00150 #define APR_OC_REASON_RUNNING 5 00157 typedef struct apr_proc_t { 00158 00159 pid_t pid; 00161 apr_file_t *in; 00163 apr_file_t *out; 00165 apr_file_t *err; 00166 #if APR_HAS_PROC_INVOKED || defined(DOXYGEN) 00167 00174 char *invoked; 00175 #endif 00176 #if defined(WIN32) || defined(DOXYGEN) 00177 00183 HANDLE hproc; 00184 #endif 00185 } apr_proc_t; 00186 00197 typedef void (apr_child_errfn_t)(apr_pool_t *proc, apr_status_t err, 00198 const char *description); 00199 00201 typedef struct apr_thread_t apr_thread_t; 00202 00204 typedef struct apr_threadattr_t apr_threadattr_t; 00205 00207 typedef struct apr_procattr_t apr_procattr_t; 00208 00210 typedef struct apr_thread_once_t apr_thread_once_t; 00211 00213 typedef struct apr_threadkey_t apr_threadkey_t; 00214 00216 typedef struct apr_other_child_rec_t apr_other_child_rec_t; 00217 00221 typedef void *(APR_THREAD_FUNC *apr_thread_start_t)(apr_thread_t*, void*); 00222 00223 typedef enum { 00224 APR_KILL_NEVER, 00225 APR_KILL_ALWAYS, 00226 APR_KILL_AFTER_TIMEOUT, 00227 APR_JUST_WAIT, 00228 APR_KILL_ONLY_ONCE 00229 } apr_kill_conditions_e; 00230 00231 /* Thread Function definitions */ 00232 00233 #if APR_HAS_THREADS 00234 00240 APR_DECLARE(apr_status_t) apr_threadattr_create(apr_threadattr_t **new_attr, 00241 apr_pool_t *cont); 00242 00248 APR_DECLARE(apr_status_t) apr_threadattr_detach_set(apr_threadattr_t *attr, 00249 apr_int32_t on); 00250 00255 APR_DECLARE(apr_status_t) apr_threadattr_detach_get(apr_threadattr_t *attr); 00256 00262 APR_DECLARE(apr_status_t) apr_threadattr_stacksize_set(apr_threadattr_t *attr, 00263 apr_size_t stacksize); 00264 00275 APR_DECLARE(apr_status_t) apr_threadattr_guardsize_set(apr_threadattr_t *attr, 00276 apr_size_t guardsize); 00277 00286 APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new_thread, 00287 apr_threadattr_t *attr, 00288 apr_thread_start_t func, 00289 void *data, apr_pool_t *cont); 00290 00296 APR_DECLARE(apr_status_t) apr_thread_exit(apr_thread_t *thd, 00297 apr_status_t retval); 00298 00304 APR_DECLARE(apr_status_t) apr_thread_join(apr_status_t *retval, 00305 apr_thread_t *thd); 00306 00310 APR_DECLARE(void) apr_thread_yield(void); 00311 00318 APR_DECLARE(apr_status_t) apr_thread_once_init(apr_thread_once_t **control, 00319 apr_pool_t *p); 00320 00330 APR_DECLARE(apr_status_t) apr_thread_once(apr_thread_once_t *control, 00331 void (*func)(void)); 00332 00337 APR_DECLARE(apr_status_t) apr_thread_detach(apr_thread_t *thd); 00338 00345 APR_DECLARE(apr_status_t) apr_thread_data_get(void **data, const char *key, 00346 apr_thread_t *thread); 00347 00355 APR_DECLARE(apr_status_t) apr_thread_data_set(void *data, const char *key, 00356 apr_status_t (*cleanup) (void *), 00357 apr_thread_t *thread); 00358 00365 APR_DECLARE(apr_status_t) apr_threadkey_private_create(apr_threadkey_t **key, 00366 void (*dest)(void *), 00367 apr_pool_t *cont); 00368 00374 APR_DECLARE(apr_status_t) apr_threadkey_private_get(void **new_mem, 00375 apr_threadkey_t *key); 00376 00382 APR_DECLARE(apr_status_t) apr_threadkey_private_set(void *priv, 00383 apr_threadkey_t *key); 00384 00389 APR_DECLARE(apr_status_t) apr_threadkey_private_delete(apr_threadkey_t *key); 00390 00397 APR_DECLARE(apr_status_t) apr_threadkey_data_get(void **data, const char *key, 00398 apr_threadkey_t *threadkey); 00399 00407 APR_DECLARE(apr_status_t) apr_threadkey_data_set(void *data, const char *key, 00408 apr_status_t (*cleanup) (void *), 00409 apr_threadkey_t *threadkey); 00410 00411 #endif 00412 00418 APR_DECLARE(apr_status_t) apr_procattr_create(apr_procattr_t **new_attr, 00419 apr_pool_t *cont); 00420 00429 APR_DECLARE(apr_status_t) apr_procattr_io_set(apr_procattr_t *attr, 00430 apr_int32_t in, apr_int32_t out, 00431 apr_int32_t err); 00432 00445 APR_DECLARE(apr_status_t) apr_procattr_child_in_set(struct apr_procattr_t *attr, 00446 apr_file_t *child_in, 00447 apr_file_t *parent_in); 00448 00459 APR_DECLARE(apr_status_t) apr_procattr_child_out_set(struct apr_procattr_t *attr, 00460 apr_file_t *child_out, 00461 apr_file_t *parent_out); 00462 00473 APR_DECLARE(apr_status_t) apr_procattr_child_err_set(struct apr_procattr_t *attr, 00474 apr_file_t *child_err, 00475 apr_file_t *parent_err); 00476 00484 APR_DECLARE(apr_status_t) apr_procattr_dir_set(apr_procattr_t *attr, 00485 const char *dir); 00486 00498 APR_DECLARE(apr_status_t) apr_procattr_cmdtype_set(apr_procattr_t *attr, 00499 apr_cmdtype_e cmd); 00500 00506 APR_DECLARE(apr_status_t) apr_procattr_detach_set(apr_procattr_t *attr, 00507 apr_int32_t detach); 00508 00509 #if APR_HAVE_STRUCT_RLIMIT 00522 APR_DECLARE(apr_status_t) apr_procattr_limit_set(apr_procattr_t *attr, 00523 apr_int32_t what, 00524 struct rlimit *limit); 00525 #endif 00526 00538 APR_DECLARE(apr_status_t) apr_procattr_child_errfn_set(apr_procattr_t *attr, 00539 apr_child_errfn_t *errfn); 00540 00553 APR_DECLARE(apr_status_t) apr_procattr_error_check_set(apr_procattr_t *attr, 00554 apr_int32_t chk); 00555 00556 #if APR_HAS_FORK 00563 APR_DECLARE(apr_status_t) apr_proc_fork(apr_proc_t *proc, apr_pool_t *cont); 00564 #endif 00565 00580 APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new_proc, 00581 const char *progname, 00582 const char * const *args, 00583 const char * const *env, 00584 apr_procattr_t *attr, 00585 apr_pool_t *cont); 00586 00613 APR_DECLARE(apr_status_t) apr_proc_wait(apr_proc_t *proc, 00614 int *exitcode, apr_exit_why_e *exitwhy, 00615 apr_wait_how_e waithow); 00616 00643 APR_DECLARE(apr_status_t) apr_proc_wait_all_procs(apr_proc_t *proc, 00644 int *exitcode, 00645 apr_exit_why_e *exitwhy, 00646 apr_wait_how_e waithow, 00647 apr_pool_t *p); 00648 00649 #define APR_PROC_DETACH_FOREGROUND 0 00650 #define APR_PROC_DETACH_DAEMONIZE 1 00658 APR_DECLARE(apr_status_t) apr_proc_detach(int daemonize); 00659 00677 APR_DECLARE(void) apr_proc_other_child_register(apr_proc_t *proc, 00678 void (*maintenance) (int reason, 00679 void *, 00680 int status), 00681 void *data, apr_file_t *write_fd, 00682 apr_pool_t *p); 00683 00693 APR_DECLARE(void) apr_proc_other_child_unregister(void *data); 00694 00715 APR_DECLARE(apr_status_t) apr_proc_other_child_alert(apr_proc_t *proc, 00716 int reason, 00717 int status); 00718 00726 APR_DECLARE(void) apr_proc_other_child_refresh(apr_other_child_rec_t *ocr, 00727 int reason); 00728 00735 APR_DECLARE(void) apr_proc_other_child_refresh_all(int reason); 00736 00743 APR_DECLARE(void) apr_proc_other_child_check(void); 00744 00748 APR_DECLARE(apr_status_t) apr_proc_other_child_read(apr_proc_t *proc, int status); 00749 00750 00756 APR_DECLARE(apr_status_t) apr_proc_kill(apr_proc_t *proc, int sig); 00757 00771 APR_DECLARE(void) apr_pool_note_subprocess(apr_pool_t *a, apr_proc_t *proc, 00772 apr_kill_conditions_e how); 00773 00774 #if APR_HAS_THREADS 00775 00776 #if (APR_HAVE_SIGWAIT || APR_HAVE_SIGSUSPEND) && !defined(OS2) 00777 00782 APR_DECLARE(apr_status_t) apr_setup_signal_thread(void); 00783 00791 APR_DECLARE(apr_status_t) apr_signal_thread(int(*signal_handler)(int signum)); 00792 00793 #endif /* (APR_HAVE_SIGWAIT || APR_HAVE_SIGSUSPEND) && !defined(OS2) */ 00794 00799 APR_POOL_DECLARE_ACCESSOR(thread); 00800 00801 #endif /* APR_HAS_THREADS */ 00802 00805 #ifdef __cplusplus 00806 } 00807 #endif 00808 00809 #endif /* ! APR_THREAD_PROC_H */ 00810

Generated on Wed Sep 1 05:15:08 2004 for Apache Portable Runtime by doxygen 1.3.8