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

« back to all changes in this revision

Viewing changes to srclib/apr/dso/os390/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_portable.h"
 
18
#include "apr_strings.h"
 
19
#include "apr_arch_dso.h"
 
20
#include <errno.h>
 
21
#include <string.h>
 
22
 
 
23
#if APR_HAS_DSO
 
24
 
 
25
APR_DECLARE(apr_status_t) apr_os_dso_handle_put(apr_dso_handle_t **aprdso,
 
26
                                                apr_os_dso_handle_t osdso,
 
27
                                                apr_pool_t *pool)
 
28
{   
 
29
    *aprdso = apr_pcalloc(pool, sizeof **aprdso);
 
30
    (*aprdso)->handle = osdso;
 
31
    (*aprdso)->pool = pool;
 
32
    return APR_SUCCESS;
 
33
}
 
34
 
 
35
APR_DECLARE(apr_status_t) apr_os_dso_handle_get(apr_os_dso_handle_t *osdso,
 
36
                                                apr_dso_handle_t *aprdso)
 
37
{
 
38
    *osdso = aprdso->handle;
 
39
    return APR_SUCCESS;
 
40
}
 
41
 
 
42
static apr_status_t dso_cleanup(void *thedso)
 
43
{
 
44
    apr_dso_handle_t *dso = thedso;
 
45
    int rc;
 
46
 
 
47
    if (dso->handle == 0)
 
48
        return APR_SUCCESS;
 
49
       
 
50
    rc = dllfree(dso->handle);
 
51
 
 
52
    if (rc == 0) {
 
53
        dso->handle = 0;
 
54
        return APR_SUCCESS;
 
55
    }
 
56
    dso->failing_errno = errno;
 
57
    return errno;
 
58
}
 
59
 
 
60
APR_DECLARE(apr_status_t) apr_dso_load(apr_dso_handle_t **res_handle, 
 
61
                                       const char *path, apr_pool_t *ctx)
 
62
{
 
63
    dllhandle *handle;
 
64
    int rc;
 
65
 
 
66
    *res_handle = apr_pcalloc(ctx, sizeof(*res_handle));
 
67
    (*res_handle)->pool = ctx;
 
68
    if ((handle = dllload(path)) != NULL) {
 
69
        (*res_handle)->handle  = handle;
 
70
        apr_pool_cleanup_register(ctx, *res_handle, dso_cleanup, apr_pool_cleanup_null);
 
71
        return APR_SUCCESS;
 
72
    }
 
73
 
 
74
    (*res_handle)->failing_errno = errno;
 
75
    return errno;
 
76
}
 
77
 
 
78
APR_DECLARE(apr_status_t) apr_dso_unload(apr_dso_handle_t *handle)
 
79
{
 
80
    return apr_pool_cleanup_run(handle->pool, handle, dso_cleanup);
 
81
}
 
82
 
 
83
APR_DECLARE(apr_status_t) apr_dso_sym(apr_dso_handle_sym_t *ressym, 
 
84
                                      apr_dso_handle_t *handle, 
 
85
                                      const char *symname)
 
86
{
 
87
    void *func_ptr;
 
88
    void *var_ptr; 
 
89
 
 
90
    if ((var_ptr = dllqueryvar(handle->handle, symname)) != NULL) {
 
91
        *ressym = var_ptr;
 
92
        return APR_SUCCESS;
 
93
    }
 
94
    if ((func_ptr = (void *)dllqueryfn(handle->handle, symname)) != NULL) {
 
95
        *ressym = func_ptr;
 
96
        return APR_SUCCESS;
 
97
    }
 
98
    handle->failing_errno = errno;
 
99
    return errno;
 
100
}
 
101
 
 
102
APR_DECLARE(const char *) apr_dso_error(apr_dso_handle_t *handle, char *buffer, 
 
103
                          apr_size_t buflen)
 
104
{
 
105
    apr_cpystrn(buffer, strerror(handle->failing_errno), buflen);
 
106
    return buffer;
 
107
}
 
108
 
 
109
#endif