~ubuntu-branches/ubuntu/feisty/apache2/feisty

« back to all changes in this revision

Viewing changes to srclib/apr/dso/beos/dso.c

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Barth
  • Date: 2006-12-09 21:05:45 UTC
  • mfrom: (0.6.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20061209210545-h70s0xaqc2v8vqr2
Tags: 2.2.3-3.2
* Non-maintainer upload.
* 043_ajp_connection_reuse: Patch from upstream Bugzilla, fixing a critical
  issue with regard to connection reuse in mod_proxy_ajp.
  Closes: #396265

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as
 
2
 * applicable.
 
3
 *
 
4
 * Licensed under the Apache License, Version 2.0 (the "License");
 
5
 * you may not use this file except in compliance with the License.
 
6
 * 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_arch_dso.h"
 
18
#include "apr_portable.h"
 
19
 
 
20
#if APR_HAS_DSO
 
21
 
 
22
static apr_status_t dso_cleanup(void *thedso)
 
23
{
 
24
    apr_dso_handle_t *dso = thedso;
 
25
 
 
26
    if (dso->handle > 0 && unload_add_on(dso->handle) < B_NO_ERROR)
 
27
        return APR_EINIT;
 
28
    dso->handle = -1;
 
29
 
 
30
    return APR_SUCCESS;
 
31
}
 
32
 
 
33
APR_DECLARE(apr_status_t) apr_dso_load(apr_dso_handle_t **res_handle, 
 
34
                                       const char *path, apr_pool_t *pool)
 
35
{
 
36
    image_id newid = -1;
 
37
 
 
38
    *res_handle = apr_pcalloc(pool, sizeof(*res_handle));
 
39
 
 
40
    if((newid = load_add_on(path)) < B_NO_ERROR) {
 
41
        (*res_handle)->errormsg = strerror(newid);
 
42
        return APR_EDSOOPEN;
 
43
        }
 
44
        
 
45
    (*res_handle)->pool = pool;
 
46
    (*res_handle)->handle = newid;
 
47
 
 
48
    apr_pool_cleanup_register(pool, *res_handle, dso_cleanup, apr_pool_cleanup_null);
 
49
 
 
50
    return APR_SUCCESS;
 
51
}
 
52
 
 
53
APR_DECLARE(apr_status_t) apr_dso_unload(apr_dso_handle_t *handle)
 
54
{
 
55
    return apr_pool_cleanup_run(handle->pool, handle, dso_cleanup);
 
56
}
 
57
 
 
58
APR_DECLARE(apr_status_t) apr_dso_sym(apr_dso_handle_sym_t *ressym, apr_dso_handle_t *handle,
 
59
               const char *symname)
 
60
{
 
61
    int err;
 
62
 
 
63
    if (symname == NULL)
 
64
        return APR_ESYMNOTFOUND;
 
65
 
 
66
    err = get_image_symbol(handle->handle, symname, B_SYMBOL_TYPE_ANY, 
 
67
                         ressym);
 
68
 
 
69
    if(err != B_OK)
 
70
        return APR_ESYMNOTFOUND;
 
71
 
 
72
    return APR_SUCCESS;
 
73
}
 
74
 
 
75
APR_DECLARE(const char *) apr_dso_error(apr_dso_handle_t *dso, char *buffer, apr_size_t buflen)
 
76
{
 
77
    strncpy(buffer, strerror(errno), buflen);
 
78
    return buffer;
 
79
}
 
80
 
 
81
APR_DECLARE(apr_status_t) apr_os_dso_handle_put(apr_dso_handle_t **aprdso,
 
82
                                                apr_os_dso_handle_t osdso,
 
83
                                                apr_pool_t *pool)
 
84
{
 
85
    *aprdso = apr_pcalloc(pool, sizeof **aprdso);
 
86
    (*aprdso)->handle = osdso;
 
87
    (*aprdso)->pool = pool;
 
88
    return APR_SUCCESS;
 
89
}
 
90
 
 
91
APR_DECLARE(apr_status_t) apr_os_dso_handle_get(apr_os_dso_handle_t *osdso,
 
92
                                                apr_dso_handle_t *aprdso)
 
93
{
 
94
    *osdso = aprdso->handle;
 
95
    return APR_SUCCESS;
 
96
}
 
97
 
 
98
#endif