File: jk_ajp13_worker.c

package info (click to toggle)
libapache-mod-jk 1%3A1.2.18-3
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 5,004 kB
  • ctags: 2,664
  • sloc: ansic: 20,014; sh: 8,643; xml: 7,304; perl: 617; makefile: 321; awk: 59
file content (119 lines) | stat: -rw-r--r-- 3,537 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
 *  Copyright 1999-2004 The Apache Software Foundation
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

/***************************************************************************
 * Description: Bi-directional protocol.                                   *
 * Author:      Costin <costin@costin.dnt.ro>                              *
 * Author:      Gal Shachor <shachor@il.ibm.com>                           *
 * Author:      Henri Gomez <hgomez@apache.org>                            *
 * Version:     $Revision: 300520 $                                          *
 ***************************************************************************/

#include "jk_ajp13_worker.h"


/* -------------------- Method -------------------- */
static int JK_METHOD validate(jk_worker_t *pThis,
                              jk_map_t *props,
                              jk_worker_env_t *we, jk_logger_t *l)
{
    int rc;
    JK_TRACE_ENTER(l);
    rc = ajp_validate(pThis, props, we, l, AJP13_PROTO);
    JK_TRACE_EXIT(l);
    return rc;
}


static int JK_METHOD init(jk_worker_t *pThis,
                          jk_map_t *props,
                          jk_worker_env_t *we, jk_logger_t *l)
{
    int rc;
    ajp_worker_t *aw = ( ajp_worker_t *)pThis->worker_private;
    JK_TRACE_ENTER(l);

    pThis->retries = jk_get_worker_retries(props, aw->name,
                                           JK_RETRIES);

    rc = ajp_init(pThis, props, we, l, AJP13_PROTO);
    JK_TRACE_EXIT(l);
    return rc;
}


static int JK_METHOD destroy(jk_worker_t **pThis, jk_logger_t *l)
{
    int rc;
    JK_TRACE_ENTER(l);
    rc = ajp_destroy(pThis, l, AJP13_PROTO);
    JK_TRACE_EXIT(l);
    return rc;
}


static int JK_METHOD get_endpoint(jk_worker_t *pThis,
                                  jk_endpoint_t **pend, jk_logger_t *l)
{
    int rc;
    JK_TRACE_ENTER(l);
    rc = ajp_get_endpoint(pThis, pend, l, AJP13_PROTO);
    JK_TRACE_EXIT(l);
    return rc;
}

int JK_METHOD ajp13_worker_factory(jk_worker_t **w,
                                   const char *name, jk_logger_t *l)
{
    ajp_worker_t *aw;

    JK_TRACE_ENTER(l);
    if (name == NULL || w == NULL) {
        JK_LOG_NULL_PARAMS(l);
        JK_TRACE_EXIT(l);
        return 0;
    }

    aw = (ajp_worker_t *) calloc(1, sizeof(ajp_worker_t));
    if (!aw) {
        jk_log(l, JK_LOG_ERROR,
               "malloc of private_data failed");
        JK_TRACE_EXIT(l);
        return 0;
    }

    aw->name = name;
    aw->proto = AJP13_PROTO;
    aw->login = NULL;

    aw->ep_cache_sz = 0;
    aw->ep_cache = NULL;
    aw->connect_retry_attempts = AJP_DEF_RETRY_ATTEMPTS;
    aw->worker.worker_private = aw;

    aw->worker.validate = validate;
    aw->worker.init = init;
    aw->worker.get_endpoint = get_endpoint;
    aw->worker.destroy = destroy;
    aw->worker.maintain = ajp_maintain;
    aw->worker.retries = JK_RETRIES;

    aw->logon = NULL;           /* No Logon on AJP13 */

    *w = &aw->worker;
    JK_TRACE_EXIT(l);
    return JK_AJP13_WORKER_TYPE;
}