Apache HTTPD
ajp_utils.c
Go to the documentation of this file.
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 "ajp.h"
18
20
21/*
22 * Handle the CPING/CPONG
23 */
27{
28 ajp_msg_t *msg;
29 apr_status_t rc, rv;
32
34 "Into ajp_handle_cping_cpong");
35
37 if (rc != APR_SUCCESS) {
39 "ajp_handle_cping_cpong: ajp_msg_create failed");
40 return rc;
41 }
42
44 if (rc != APR_SUCCESS) {
46 "ajp_handle_cping_cpong: ajp_marshal_into_msgb failed");
47 return rc;
48 }
49
50 rc = ajp_ilink_send(sock, msg);
51 ajp_msg_log(r, msg, "ajp_handle_cping_cpong: ajp_ilink_send packet dump");
52 if (rc != APR_SUCCESS) {
54 "ajp_handle_cping_cpong: ajp_ilink_send failed");
55 return rc;
56 }
57
59 if (rc != APR_SUCCESS) {
61 "ajp_handle_cping_cpong: apr_socket_timeout_get failed");
62 return rc;
63 }
64
65 /* Set CPING/CPONG response timeout */
67 if (rc != APR_SUCCESS) {
69 "ajp_handle_cping_cpong: apr_socket_timeout_set failed");
70 return rc;
71 }
72 ajp_msg_reuse(msg);
73
74 /* Read CPONG reply */
75 rv = ajp_ilink_receive(sock, msg);
76 if (rv != APR_SUCCESS) {
78 "ajp_handle_cping_cpong: ajp_ilink_receive failed");
79 goto cleanup;
80 }
81
82 ajp_msg_log(r, msg, "ajp_handle_cping_cpong: ajp_ilink_receive packet dump");
83 rv = ajp_msg_get_uint8(msg, &result);
84 if (rv != APR_SUCCESS) {
86 "ajp_handle_cping_cpong: invalid CPONG message");
87 goto cleanup;
88 }
89 if (result != CMD_AJP13_CPONG) {
91 "ajp_handle_cping_cpong: awaited CPONG, received %d ",
92 result);
93 rv = APR_EGENERAL;
94 goto cleanup;
95 }
96
98 /* Restore original socket timeout */
100 if (rc != APR_SUCCESS) {
102 "ajp_handle_cping_cpong: apr_socket_timeout_set failed");
103 return rc;
104 }
105
107 "ajp_handle_cping_cpong: Done");
108 return rv;
109}
110
111
112#define case_to_str(x) case CMD_AJP13_##x:\
113 return #x;\
114 break;
115
121const char *ajp_type_str(int type)
122{
123 switch (type) {
133 default:
134 return "CMD_AJP13_UNKNOWN";
135 }
136
137}
Apache Jserv Protocol.
#define case_to_str(x)
Definition ajp_utils.c:112
apr_status_t ajp_msg_create(apr_pool_t *pool, apr_size_t size, ajp_msg_t **rmsg)
Definition ajp_msg.c:561
apr_status_t ajp_msg_reuse(ajp_msg_t *msg)
Definition ajp_msg.c:204
apr_status_t ajp_msg_log(request_rec *r, ajp_msg_t *msg, char *err)
Definition ajp_msg.c:115
apr_status_t ajp_msg_serialize_cping(ajp_msg_t *msg)
Definition ajp_msg.c:632
apr_status_t ajp_ilink_receive(apr_socket_t *sock, ajp_msg_t *msg)
Definition ajp_link.c:74
apr_status_t ajp_msg_get_uint8(ajp_msg_t *msg, apr_byte_t *rvalue)
Definition ajp_msg.c:482
const char * ajp_type_str(int type)
Definition ajp_utils.c:121
apr_status_t ajp_ilink_send(apr_socket_t *sock, ajp_msg_t *msg)
Definition ajp_link.c:21
#define CMD_AJP13_CPONG
Definition ajp.h:155
#define AJP_PING_PONG_SZ
Definition ajp.h:138
#define APLOG_USE_MODULE(foo)
request_rec * r
#define APLOG_TRACE8
Definition http_log.h:79
#define APLOGNO(n)
Definition http_log.h:117
#define ap_log_rerror
Definition http_log.h:454
#define APLOG_ERR
Definition http_log.h:67
#define APLOG_MARK
Definition http_log.h:283
#define APR_EGENERAL
Definition apr_errno.h:313
apr_redis_t * rc
Definition apr_redis.h:173
@ CPING
Definition mod_proxy.h:84
apr_size_t size
#define APR_SUCCESS
Definition apr_errno.h:225
int apr_status_t
Definition apr_errno.h:44
void const char apr_status_t(* cleanup)(void *))
int type
apr_array_header_t ** result
apr_socket_t * sock
apr_int64_t apr_interval_time_t
Definition apr_time.h:55
static apr_OFN_ajp_handle_cping_cpong_t * ajp_handle_cping_cpong
Definition ajp.h:113
A structure that represents the current request.
Definition httpd.h:845
apr_pool_t * pool
Definition httpd.h:847
apr_status_t apr_socket_timeout_set(apr_socket_t *sock, apr_interval_time_t t)
Definition sockopt.c:75
apr_status_t apr_socket_timeout_get(apr_socket_t *sock, apr_interval_time_t *t)
Definition sockopt.c:355
IN ULONG IN INT timeout