| 128 | } |
| 129 | |
| 130 | static int process_echo_connection(conn_rec *c) |
| 131 | { |
| 132 | apr_bucket_brigade *bb; |
| 133 | apr_bucket *b; |
| 134 | apr_socket_t *csd = NULL; |
| 135 | EchoConfig *pConfig = ap_get_module_config(c->base_server->module_config, |
| 136 | &echo_module); |
| 137 | |
| 138 | if (!pConfig->bEnabled) { |
| 139 | return DECLINED; |
| 140 | } |
| 141 | |
| 142 | ap_time_process_request(c->sbh, START_PREQUEST); |
| 143 | update_echo_child_status(c->sbh, SERVER_BUSY_READ, c, NULL); |
| 144 | |
| 145 | bb = apr_brigade_create(c->pool, c->bucket_alloc); |
| 146 | |
| 147 | for ( ; ; ) { |
| 148 | apr_status_t rv; |
| 149 | |
| 150 | /* Get a single line of input from the client */ |
| 151 | if (((rv = ap_get_brigade(c->input_filters, bb, AP_MODE_GETLINE, |
| 152 | APR_BLOCK_READ, 0)) != APR_SUCCESS)) { |
| 153 | apr_brigade_cleanup(bb); |
| 154 | if (!APR_STATUS_IS_EOF(rv) && ! APR_STATUS_IS_TIMEUP(rv)) |
| 155 | ap_log_error(APLOG_MARK, APLOG_INFO, rv, c->base_server, APLOGNO(01611) |
| 156 | "ProtocolEcho: Failure reading from %s", |
| 157 | c->client_ip); |
| 158 | break; |
| 159 | } |
| 160 | |
| 161 | /* Something horribly wrong happened. Someone didn't block! */ |
| 162 | if (APR_BRIGADE_EMPTY(bb)) { |
| 163 | ap_log_error(APLOG_MARK, APLOG_INFO, rv, c->base_server, APLOGNO(01612) |
| 164 | "ProtocolEcho: Error - read empty brigade from %s!", |
| 165 | c->client_ip); |
| 166 | break; |
| 167 | } |
| 168 | |
| 169 | if (!csd) { |
| 170 | csd = ap_get_conn_socket(c); |
| 171 | apr_socket_timeout_set(csd, c->base_server->keep_alive_timeout); |
| 172 | } |
| 173 | |
| 174 | update_echo_child_status(c->sbh, SERVER_BUSY_WRITE, NULL, bb); |
| 175 | |
| 176 | /* Make sure the data is flushed to the client */ |
| 177 | b = apr_bucket_flush_create(c->bucket_alloc); |
| 178 | APR_BRIGADE_INSERT_TAIL(bb, b); |
| 179 | rv = ap_pass_brigade(c->output_filters, bb); |
| 180 | if (rv != APR_SUCCESS) { |
| 181 | ap_log_error(APLOG_MARK, APLOG_INFO, rv, c->base_server, APLOGNO(01613) |
| 182 | "ProtocolEcho: Failure writing to %s", |
| 183 | c->client_ip); |
| 184 | break; |
| 185 | } |
| 186 | apr_brigade_cleanup(bb); |
| 187 |
nothing calls this directly
no test coverage detected