Apache2
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
apr_thread_proc.h
Go to the documentation of this file.
1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2  * contributor license agreements. See the NOTICE file distributed with
3  * this work for additional information regarding copyright ownership.
4  * The ASF licenses this file to You under the Apache License, Version 2.0
5  * (the "License"); you may not use this file except in compliance with
6  * the License. You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef APR_THREAD_PROC_H
18 #define APR_THREAD_PROC_H
19 
25 #include "apr.h"
26 #include "apr_file_io.h"
27 #include "apr_pools.h"
28 #include "apr_errno.h"
29 #include "apr_perms_set.h"
30 
31 #if APR_HAVE_STRUCT_RLIMIT
32 #include <sys/time.h>
33 #include <sys/resource.h>
34 #endif
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif /* __cplusplus */
39 
46 typedef enum {
55 
56 typedef enum {
60 
61 /* I am specifically calling out the values so that the macros below make
62  * more sense. Yes, I know I don't need to, but I am hoping this makes what
63  * I am doing more clear. If you want to add more reasons to exit, continue
64  * to use bitmasks.
65  */
66 typedef enum {
71 
73 #define APR_PROC_CHECK_EXIT(x) (x & APR_PROC_EXIT)
74 
75 #define APR_PROC_CHECK_SIGNALED(x) (x & APR_PROC_SIGNAL)
76 
77 #define APR_PROC_CHECK_CORE_DUMP(x) (x & APR_PROC_SIGNAL_CORE)
78 
80 #define APR_NO_PIPE 0
81 
82 #define APR_FULL_BLOCK 1
83 
84 #define APR_FULL_NONBLOCK 2
85 
86 #define APR_PARENT_BLOCK 3
87 
88 #define APR_CHILD_BLOCK 4
89 
90 #define APR_NO_FILE 8
91 
93 #define APR_READ_BLOCK 3
94 
95 #define APR_WRITE_BLOCK 4
96 
100 #define APR_NO_FILE 8
101 
103 #define APR_LIMIT_CPU 0
104 
105 #define APR_LIMIT_MEM 1
106 
107 #define APR_LIMIT_NPROC 2
108 
109 #define APR_LIMIT_NOFILE 3
110 
115 #define APR_OC_REASON_DEATH 0
117 #define APR_OC_REASON_UNWRITABLE 1
118 #define APR_OC_REASON_RESTART 2
122 #define APR_OC_REASON_UNREGISTER 3
125 #define APR_OC_REASON_LOST 4
127 #define APR_OC_REASON_RUNNING 5
134 typedef struct apr_proc_t {
135 
136  pid_t pid;
138  apr_file_t *in;
140  apr_file_t *out;
142  apr_file_t *err;
143 #if APR_HAS_PROC_INVOKED || defined(DOXYGEN)
151  char *invoked;
152 #endif
153 #if defined(WIN32) || defined(DOXYGEN)
154 
160  HANDLE hproc;
161 #endif
162 } apr_proc_t;
163 
175  const char *description);
176 
178 typedef struct apr_thread_t apr_thread_t;
179 
181 typedef struct apr_threadattr_t apr_threadattr_t;
182 
185 
187 typedef struct apr_thread_once_t apr_thread_once_t;
190 typedef struct apr_threadkey_t apr_threadkey_t;
198 typedef void *(APR_THREAD_FUNC *apr_thread_start_t)(apr_thread_t*, void*);
199 
200 typedef enum {
206  APR_JUST_WAIT,
209 
210 /* Thread Function definitions */
212 #if APR_HAS_THREADS
213 
220  apr_pool_t *cont);
221 
228  apr_int32_t on);
229 
237 
244  apr_size_t stacksize);
245 
257  apr_size_t guardsize);
258 
268  apr_threadattr_t *attr,
269  apr_thread_start_t func,
270  void *data, apr_pool_t *cont);
271 
278  apr_status_t retval);
279 
286  apr_thread_t *thd);
287 
291 APR_DECLARE(void) apr_thread_yield(void);
292 
300  apr_pool_t *p);
301 
312  void (*func)(void));
313 
319 
326 APR_DECLARE(apr_status_t) apr_thread_data_get(void **data, const char *key,
327  apr_thread_t *thread);
328 
336 APR_DECLARE(apr_status_t) apr_thread_data_set(void *data, const char *key,
337  apr_status_t (*cleanup) (void *),
338  apr_thread_t *thread);
339 
347  void (*dest)(void *),
348  apr_pool_t *cont);
349 
356  apr_threadkey_t *key);
357 
364  apr_threadkey_t *key);
365 
371 
378 APR_DECLARE(apr_status_t) apr_threadkey_data_get(void **data, const char *key,
379  apr_threadkey_t *threadkey);
380 
388 APR_DECLARE(apr_status_t) apr_threadkey_data_set(void *data, const char *key,
389  apr_status_t (*cleanup) (void *),
390  apr_threadkey_t *threadkey);
391 
392 #endif
393 
400  apr_pool_t *cont);
401 
417  apr_int32_t in, apr_int32_t out,
418  apr_int32_t err);
419 
436  apr_file_t *child_in,
437  apr_file_t *parent_in);
438 
453  apr_file_t *child_out,
454  apr_file_t *parent_out);
455 
470  apr_file_t *child_err,
471  apr_file_t *parent_err);
472 
481  const char *dir);
482 
495  apr_cmdtype_e cmd);
496 
503  apr_int32_t detach);
504 
505 #if APR_HAVE_STRUCT_RLIMIT
506 
520  struct rlimit *limit);
521 #endif
522 
535  apr_child_errfn_t *errfn);
536 
550  apr_int32_t chk);
551 
560  apr_int32_t addrspace);
561 
571  const char *username,
572  const char *password);
573 
580  const char *groupname);
581 
582 
591  apr_perms_setfn_t *perms_set_fn,
592  void *data,
593  apr_fileperms_t perms);
594 
595 #if APR_HAS_FORK
596 
605 #endif
606 
624  const char *progname,
625  const char * const *args,
626  const char * const *env,
627  apr_procattr_t *attr,
628  apr_pool_t *pool);
629 
657  int *exitcode, apr_exit_why_e *exitwhy,
658  apr_wait_how_e waithow);
659 
687  int *exitcode,
688  apr_exit_why_e *exitwhy,
689  apr_wait_how_e waithow,
690  apr_pool_t *p);
691 
692 #define APR_PROC_DETACH_FOREGROUND 0
693 #define APR_PROC_DETACH_DAEMONIZE 1
701 APR_DECLARE(apr_status_t) apr_proc_detach(int daemonize);
716  void (*maintenance) (int reason,
717  void *,
718  int status),
719  void *data, apr_file_t *write_fd,
720  apr_pool_t *p);
721 
732 
754  int reason,
755  int status);
756 
765  int reason);
766 
774 
781 
797 
798 #if APR_HAS_THREADS
799 
800 #if (APR_HAVE_SIGWAIT || APR_HAVE_SIGSUSPEND) && !defined(OS2)
801 
807 
815 APR_DECLARE(apr_status_t) apr_signal_thread(int(*signal_handler)(int signum));
816 
817 #endif /* (APR_HAVE_SIGWAIT || APR_HAVE_SIGSUSPEND) && !defined(OS2) */
818 
824 
825 #endif /* APR_HAS_THREADS */
826 
829 #ifdef __cplusplus
830 }
831 #endif
832 
833 #endif /* ! APR_THREAD_PROC_H */
834 
size_t apr_size_t
Definition: apr.h:375
Definition: apr_arch_misc.h:52
apr_status_t apr_procattr_io_set(apr_procattr_t *attr, apr_int32_t in, apr_int32_t out, apr_int32_t err)
apr_status_t apr_proc_fork(apr_proc_t *proc, apr_pool_t *cont)
Definition: apr_thread_proc.h:67
apr_status_t apr_thread_detach(apr_thread_t *thd)
void apr_proc_other_child_unregister(void *data)
APR Process Locking Routines.
apr_status_t apr_threadkey_private_get(void **new_mem, apr_threadkey_t *key)
apr_status_t apr_procattr_limit_set(apr_procattr_t *attr, apr_int32_t what, struct rlimit *limit)
Definition: apr_arch_file_io.h:107
Definition: apr_thread_proc.h:47
void( apr_child_errfn_t)(apr_pool_t *proc, apr_status_t err, const char *description)
Definition: apr_thread_proc.h:184
Definition: apr_thread_proc.h:57
apr_status_t apr_threadattr_stacksize_set(apr_threadattr_t *attr, apr_size_t stacksize)
apr_bucket_brigade request_rec apr_pool_t * pool
Definition: mod_dav.h:552
apr_status_t apr_proc_kill(apr_proc_t *proc, int sig)
apr_status_t apr_threadkey_private_delete(apr_threadkey_t *key)
apr_status_t apr_procattr_group_set(apr_procattr_t *attr, const char *groupname)
Definition: apr_thread_proc.h:144
void(* maintenance)(int, void *, int)
Definition: apr_arch_misc.h:56
apr_status_t apr_procattr_perms_set_register(apr_procattr_t *attr, apr_perms_setfn_t *perms_set_fn, void *data, apr_fileperms_t perms)
apr_status_t apr_thread_once(apr_thread_once_t *control, void(*func)(void))
void apr_proc_other_child_register(apr_proc_t *proc, void(*maintenance)(int reason, void *, int status), void *data, apr_file_t *write_fd, apr_pool_t *p)
APR File I/O Handling.
void *(APR_THREAD_FUNC * apr_thread_start_t)(apr_thread_t *, void *)
Definition: apr_thread_proc.h:208
apr_status_t apr_procattr_cmdtype_set(apr_procattr_t *attr, apr_cmdtype_e cmd)
apr_status_t apr_procattr_child_err_set(struct apr_procattr_t *attr, apr_file_t *child_err, apr_file_t *parent_err)
apr_proc_t * proc
Definition: apr_arch_misc.h:55
Definition: apr_thread_proc.h:217
apr_status_t apr_threadattr_guardsize_set(apr_threadattr_t *attr, apr_size_t guardsize)
void apr_pool_note_subprocess(apr_pool_t *a, apr_proc_t *proc, apr_kill_conditions_e how)
apr_status_t apr_procattr_child_out_set(struct apr_procattr_t *attr, apr_file_t *child_out, apr_file_t *parent_out)
apr_status_t apr_signal_thread(int(*signal_handler)(int signum))
Definition: apr_arch_threadproc.h:89
apr_status_t apr_proc_wait(apr_proc_t *proc, int *exitcode, apr_exit_why_e *exitwhy, apr_wait_how_e waithow)
Definition: apr_thread_proc.h:58
Definition: apr_thread_proc.h:211
apr_status_t apr_thread_data_get(void **data, const char *key, apr_thread_t *thread)
APR memory allocation.
apr_status_t apr_proc_other_child_alert(apr_proc_t *proc, int reason, int status)
apr_status_t apr_thread_create(apr_thread_t **new_thread, apr_threadattr_t *attr, apr_thread_start_t func, void *data, apr_pool_t *cont)
APR_POOL_DECLARE_ACCESSOR(thread)
apr_status_t apr_thread_join(apr_status_t *retval, apr_thread_t *thd)
apr_status_t apr_procattr_user_set(apr_procattr_t *attr, const char *username, const char *password)
void apr_proc_other_child_refresh(apr_other_child_rec_t *ocr, int reason)
apr_int32_t apr_fileperms_t
Definition: apr_file_info.h:125
apr_status_t apr_procattr_error_check_set(apr_procattr_t *attr, apr_int32_t chk)
apr_status_t apr_proc_create(apr_proc_t *new_proc, const char *progname, const char *const *args, const char *const *env, apr_procattr_t *attr, apr_pool_t *pool)
dav_error * err
Definition: mod_dav.h:203
apr_cmdtype_e
Definition: apr_thread_proc.h:46
Definition: apr_arch_threadproc.h:42
APR Error Codes.
Definition: apr_thread_proc.h:215
apr_status_t apr_procattr_detach_set(apr_procattr_t *attr, apr_int32_t detach)
Definition: apr_thread_proc.h:49
apr_kill_conditions_e
Definition: apr_thread_proc.h:210
void * data
Definition: apr_arch_misc.h:57
APR Platform Definitions.
#define APR_THREAD_FUNC
Definition: apr.h:475
apr_status_t apr_threadattr_detach_get(apr_threadattr_t *attr)
apr_pool_t * p
apr_status_t apr_procattr_dir_set(apr_procattr_t *attr, const char *dir)
apr_exit_why_e
Definition: apr_thread_proc.h:66
apr_status_t apr_threadattr_detach_set(apr_threadattr_t *attr, apr_int32_t on)
apr_status_t apr_proc_wait_all_procs(apr_proc_t *proc, int *exitcode, apr_exit_why_e *exitwhy, apr_wait_how_e waithow, apr_pool_t *p)
Definition: apr_thread_proc.h:51
Definition: apr_thread_proc.h:50
#define APR_DECLARE(x)
Definition: macros.h:6
Definition: apr_thread_proc.h:214
apr_status_t apr_setup_signal_thread(void)
apr_status_t apr_procattr_addrspace_set(apr_procattr_t *attr, apr_int32_t addrspace)
Definition: apr_thread_proc.h:69
int status
Definition: mod_dav.h:141
Definition: apr_arch_threadproc.h:50
const dav_resource dav_prop_insert what
Definition: mod_dav.h:994
void apr_thread_yield(void)
Definition: apr_thread_proc.h:48
apr_status_t apr_threadkey_private_set(void *priv, apr_threadkey_t *key)
struct apr_pool_t apr_pool_t
Definition: apr_pools.h:60
apr_status_t( apr_perms_setfn_t)(void *object, apr_fileperms_t perms, apr_uid_t uid, apr_gid_t gid)
Definition: apr_perms_set.h:42
typedef void(APR_THREAD_FUNC *PFN_HSE_IO_COMPLETION)(EXTENSION_CONTROL_BLOCK *ecb
int apr_status_t
Definition: apr_errno.h:44
Definition: apr_arch_threadproc.h:76
apr_status_t apr_procattr_create(apr_procattr_t **new_attr, apr_pool_t *cont)
apr_wait_how_e
Definition: apr_thread_proc.h:56
apr_status_t apr_procattr_child_in_set(struct apr_procattr_t *attr, apr_file_t *child_in, apr_file_t *parent_in)
struct apr_proc_t apr_proc_t
Definition: apr_thread_proc.h:68
apr_status_t apr_threadkey_private_create(apr_threadkey_t **key, void(*dest)(void *), apr_pool_t *cont)
Definition: apr_arch_threadproc.h:57
apr_status_t apr_threadkey_data_get(void **data, const char *key, apr_threadkey_t *threadkey)
apr_status_t apr_thread_once_init(apr_thread_once_t **control, apr_pool_t *p)
apr_status_t apr_procattr_child_errfn_set(apr_procattr_t *attr, apr_child_errfn_t *errfn)
apr_status_t apr_threadkey_data_set(void *data, const char *key, apr_status_t(*cleanup)(void *), apr_threadkey_t *threadkey)
apr_status_t apr_thread_exit(apr_thread_t *thd, apr_status_t retval)
void apr_proc_other_child_refresh_all(int reason)
apr_status_t apr_threadattr_create(apr_threadattr_t **new_attr, apr_pool_t *cont)
apr_status_t apr_thread_data_set(void *data, const char *key, apr_status_t(*cleanup)(void *), apr_thread_t *thread)
Definition: apr_thread_proc.h:216
int apr_int32_t
Definition: apr.h:333