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

« back to all changes in this revision

Viewing changes to srclib/apr/network_io/os2/os2calls.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_networkio.h"
 
18
#include "apr_network_io.h"
 
19
#include "apr_portable.h"
 
20
#include "apr_general.h"
 
21
#include "apr_lib.h"
 
22
 
 
23
static int os2_socket_init(int, int ,int);
 
24
 
 
25
int (*apr_os2_socket)(int, int, int) = os2_socket_init;
 
26
int (*apr_os2_select)(int *, int, int, int, long) = NULL;
 
27
int (*apr_os2_sock_errno)() = NULL;
 
28
int (*apr_os2_accept)(int, struct sockaddr *, int *) = NULL;
 
29
int (*apr_os2_bind)(int, struct sockaddr *, int) = NULL;
 
30
int (*apr_os2_connect)(int, struct sockaddr *, int) = NULL;
 
31
int (*apr_os2_getpeername)(int, struct sockaddr *, int *) = NULL;
 
32
int (*apr_os2_getsockname)(int, struct sockaddr *, int *) = NULL;
 
33
int (*apr_os2_getsockopt)(int, int, int, char *, int *) = NULL;
 
34
int (*apr_os2_ioctl)(int, int, caddr_t, int) = NULL;
 
35
int (*apr_os2_listen)(int, int) = NULL;
 
36
int (*apr_os2_recv)(int, char *, int, int) = NULL;
 
37
int (*apr_os2_send)(int, const char *, int, int) = NULL;
 
38
int (*apr_os2_setsockopt)(int, int, int, char *, int) = NULL;
 
39
int (*apr_os2_shutdown)(int, int) = NULL;
 
40
int (*apr_os2_soclose)(int) = NULL;
 
41
int (*apr_os2_writev)(int, struct iovec *, int) = NULL;
 
42
int (*apr_os2_sendto)(int, const char *, int, int, const struct sockaddr *, int);
 
43
int (*apr_os2_recvfrom)(int, char *, int, int, struct sockaddr *, int *);
 
44
 
 
45
static HMODULE hSO32DLL;
 
46
 
 
47
static int os2_fn_link()
 
48
{
 
49
    DosEnterCritSec(); /* Stop two threads doing this at the same time */
 
50
 
 
51
    if (apr_os2_socket == os2_socket_init) {
 
52
        ULONG rc;
 
53
        char errorstr[200];
 
54
 
 
55
        rc = DosLoadModule(errorstr, sizeof(errorstr), "SO32DLL", &hSO32DLL);
 
56
 
 
57
        if (rc)
 
58
            return APR_OS2_STATUS(rc);
 
59
 
 
60
        rc = DosQueryProcAddr(hSO32DLL, 0, "SOCKET", &apr_os2_socket);
 
61
 
 
62
        if (!rc)
 
63
            rc = DosQueryProcAddr(hSO32DLL, 0, "SELECT", &apr_os2_select);
 
64
 
 
65
        if (!rc)
 
66
            rc = DosQueryProcAddr(hSO32DLL, 0, "SOCK_ERRNO", &apr_os2_sock_errno);
 
67
 
 
68
        if (!rc)
 
69
            rc = DosQueryProcAddr(hSO32DLL, 0, "ACCEPT", &apr_os2_accept);
 
70
 
 
71
        if (!rc)
 
72
            rc = DosQueryProcAddr(hSO32DLL, 0, "BIND", &apr_os2_bind);
 
73
 
 
74
        if (!rc)
 
75
            rc = DosQueryProcAddr(hSO32DLL, 0, "CONNECT", &apr_os2_connect);
 
76
 
 
77
        if (!rc)
 
78
            rc = DosQueryProcAddr(hSO32DLL, 0, "GETPEERNAME", &apr_os2_getpeername);
 
79
 
 
80
        if (!rc)
 
81
            rc = DosQueryProcAddr(hSO32DLL, 0, "GETSOCKNAME", &apr_os2_getsockname);
 
82
 
 
83
        if (!rc)
 
84
            rc = DosQueryProcAddr(hSO32DLL, 0, "GETSOCKOPT", &apr_os2_getsockopt);
 
85
 
 
86
        if (!rc)
 
87
            rc = DosQueryProcAddr(hSO32DLL, 0, "IOCTL", &apr_os2_ioctl);
 
88
 
 
89
        if (!rc)
 
90
            rc = DosQueryProcAddr(hSO32DLL, 0, "LISTEN", &apr_os2_listen);
 
91
 
 
92
        if (!rc)
 
93
            rc = DosQueryProcAddr(hSO32DLL, 0, "RECV", &apr_os2_recv);
 
94
 
 
95
        if (!rc)
 
96
            rc = DosQueryProcAddr(hSO32DLL, 0, "SEND", &apr_os2_send);
 
97
 
 
98
        if (!rc)
 
99
            rc = DosQueryProcAddr(hSO32DLL, 0, "SETSOCKOPT", &apr_os2_setsockopt);
 
100
 
 
101
        if (!rc)
 
102
            rc = DosQueryProcAddr(hSO32DLL, 0, "SHUTDOWN", &apr_os2_shutdown);
 
103
 
 
104
        if (!rc)
 
105
            rc = DosQueryProcAddr(hSO32DLL, 0, "SOCLOSE", &apr_os2_soclose);
 
106
 
 
107
        if (!rc)
 
108
            rc = DosQueryProcAddr(hSO32DLL, 0, "WRITEV", &apr_os2_writev);
 
109
 
 
110
        if (!rc)
 
111
            rc = DosQueryProcAddr(hSO32DLL, 0, "SENDTO", &apr_os2_sendto);
 
112
 
 
113
        if (!rc)
 
114
            rc = DosQueryProcAddr(hSO32DLL, 0, "RECVFROM", &apr_os2_recvfrom);
 
115
 
 
116
        if (rc)
 
117
            return APR_OS2_STATUS(rc);
 
118
    }
 
119
 
 
120
    DosExitCritSec();
 
121
    return APR_SUCCESS;
 
122
}
 
123
 
 
124
 
 
125
 
 
126
static int os2_socket_init(int domain, int type, int protocol)
 
127
{
 
128
    int rc = os2_fn_link();
 
129
    if (rc == APR_SUCCESS)
 
130
        return apr_os2_socket(domain, type, protocol);
 
131
    return rc;
 
132
}