/src/httpd/srclib/apr/misc/unix/start.c
Line | Count | Source (jump to first uncovered line) |
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 | | #include "apr.h" |
18 | | #include "apr_general.h" |
19 | | #include "apr_pools.h" |
20 | | #include "apr_signal.h" |
21 | | #include "apr_atomic.h" |
22 | | |
23 | | #include "apr_arch_proc_mutex.h" /* for apr_proc_mutex_unix_setup_lock() */ |
24 | | #include "apr_arch_internal_time.h" |
25 | | |
26 | | |
27 | | APR_DECLARE(apr_status_t) apr_app_initialize(int *argc, |
28 | | const char * const * *argv, |
29 | | const char * const * *env) |
30 | 0 | { |
31 | | /* An absolute noop. At present, only Win32 requires this stub, but it's |
32 | | * required in order to move command arguments passed through the service |
33 | | * control manager into the process, and it's required to fix the char* |
34 | | * data passed in from win32 unicode into utf-8, win32's apr internal fmt. |
35 | | */ |
36 | 0 | return apr_initialize(); |
37 | 0 | } |
38 | | |
39 | | static int initialized = 0; |
40 | | |
41 | | APR_DECLARE(apr_status_t) apr_initialize(void) |
42 | 0 | { |
43 | 0 | apr_pool_t *pool; |
44 | 0 | apr_status_t status; |
45 | |
|
46 | 0 | if (initialized++) { |
47 | 0 | return APR_SUCCESS; |
48 | 0 | } |
49 | | |
50 | 0 | #if !defined(BEOS) && !defined(OS2) |
51 | 0 | apr_proc_mutex_unix_setup_lock(); |
52 | 0 | apr_unix_setup_time(); |
53 | 0 | #endif |
54 | |
|
55 | 0 | if ((status = apr_pool_initialize()) != APR_SUCCESS) |
56 | 0 | return status; |
57 | | |
58 | 0 | if (apr_pool_create(&pool, NULL) != APR_SUCCESS) { |
59 | 0 | return APR_ENOPOOL; |
60 | 0 | } |
61 | | |
62 | 0 | apr_pool_tag(pool, "apr_initialize"); |
63 | | |
64 | | /* apr_atomic_init() used to be called from here as well. |
65 | | * Pools rely on mutexes though, which can be backed by |
66 | | * atomics. Due to this circular dependency |
67 | | * apr_pool_initialize() is taking care of calling |
68 | | * apr_atomic_init() at the correct time. |
69 | | */ |
70 | |
|
71 | 0 | apr_signal_init(pool); |
72 | |
|
73 | 0 | return APR_SUCCESS; |
74 | 0 | } |
75 | | |
76 | | APR_DECLARE_NONSTD(void) apr_terminate(void) |
77 | 0 | { |
78 | 0 | initialized--; |
79 | 0 | if (initialized) { |
80 | 0 | return; |
81 | 0 | } |
82 | 0 | apr_pool_terminate(); |
83 | |
|
84 | 0 | } |
85 | | |
86 | | APR_DECLARE(void) apr_terminate2(void) |
87 | 0 | { |
88 | 0 | apr_terminate(); |
89 | 0 | } |