Apache HTTPD
ajp_link.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
22{
23 char *buf;
26
27 ajp_msg_end(msg);
28
29 length = msg->len;
30 buf = (char *)msg->buf;
31
32 do {
33 apr_size_t written = length;
34
35 status = apr_socket_send(sock, buf, &written);
36 if (status != APR_SUCCESS) {
38 "ajp_ilink_send(): send failed");
39 return status;
40 }
41 length -= written;
42 buf += written;
43 } while (length);
44
45 return APR_SUCCESS;
46}
47
48
51{
53 apr_size_t rdlen = 0;
55
56 while (rdlen < len) {
57
58 status = apr_socket_recv(sock, (char *)(buf + rdlen), &length);
59
60 if (status == APR_EOF)
61 return status; /* socket closed. */
63 continue;
64 else if (status != APR_SUCCESS)
65 return status; /* any error. */
66
67 rdlen += length;
68 length = len - rdlen;
69 }
70 return APR_SUCCESS;
71}
72
73
75{
78 apr_size_t blen;
79
80 hlen = msg->header_len;
81
82 status = ilink_read(sock, msg->buf, hlen);
83
84 if (status != APR_SUCCESS) {
86 "ajp_ilink_receive() can't receive header");
88 }
89
90 status = ajp_msg_check_header(msg, &blen);
91
92 if (status != APR_SUCCESS) {
94 "ajp_ilink_receive() received bad header");
95 return AJP_EBAD_HEADER;
96 }
97
98 status = ilink_read(sock, msg->buf + hlen, blen);
99
100 if (status != APR_SUCCESS) {
102 "ajp_ilink_receive() error while receiving message body "
103 "of length %" APR_SIZE_T_FMT,
104 hlen);
105 return AJP_EBAD_MESSAGE;
106 }
107
109 "ajp_ilink_receive() received packet len=%" APR_SIZE_T_FMT
110 "type=%d",
111 blen, (int)msg->buf[hlen]);
112
113 return APR_SUCCESS;
114}
115
Apache Jserv Protocol.
const char apr_size_t len
Definition ap_regex.h:187
apr_status_t ajp_msg_check_header(ajp_msg_t *msg, apr_size_t *len)
Definition ajp_msg.c:151
apr_status_t ajp_ilink_receive(apr_socket_t *sock, ajp_msg_t *msg)
Definition ajp_link.c:74
apr_status_t ajp_msg_end(ajp_msg_t *msg)
Definition ajp_msg.c:225
apr_status_t ajp_ilink_send(apr_socket_t *sock, ajp_msg_t *msg)
Definition ajp_link.c:21
#define AJP_ENO_HEADER
Definition ajp.h:97
#define AJP_EBAD_HEADER
Definition ajp.h:99
#define AJP_EBAD_MESSAGE
Definition ajp.h:101
#define APLOG_USE_MODULE(foo)
#define APLOGNO(n)
Definition http_log.h:117
#define APLOG_ERR
Definition http_log.h:67
#define ap_log_error
Definition http_log.h:370
#define APLOG_MARK
Definition http_log.h:283
#define APLOG_DEBUG
Definition http_log.h:71
const unsigned char * buf
Definition util_md5.h:50
#define APR_EOF
Definition apr_errno.h:461
#define APR_TIMEUP
Definition apr_errno.h:450
#define APR_STATUS_IS_TIMEUP(s)
Definition apr_errno.h:534
#define APR_STATUS_IS_EAGAIN(s)
Definition apr_errno.h:1272
int apr_off_t * length
apr_size_t size
#define APR_SUCCESS
Definition apr_errno.h:225
int apr_status_t
Definition apr_errno.h:44
apr_socket_t * sock
int int status
return NULL
Definition mod_so.c:359
Definition ajp.h:113
apr_size_t header_len
Definition ajp.h:117
apr_byte_t * buf
Definition ajp.h:115
apr_size_t len
Definition ajp.h:119
apr_status_t apr_socket_send(apr_socket_t *sock, const char *buf, apr_size_t *len)
Definition sendrecv.c:30
apr_status_t apr_socket_recv(apr_socket_t *sock, char *buf, apr_size_t *len)
Definition sendrecv.c:70