| 5309 | } |
| 5310 | |
| 5311 | static int core_pre_connection(conn_rec *c, void *csd) |
| 5312 | { |
| 5313 | core_net_rec *net; |
| 5314 | apr_status_t rv; |
| 5315 | |
| 5316 | if (c->master) { |
| 5317 | return DONE; |
| 5318 | } |
| 5319 | |
| 5320 | net = apr_palloc(c->pool, sizeof(*net)); |
| 5321 | /* The Nagle algorithm says that we should delay sending partial |
| 5322 | * packets in hopes of getting more data. We don't want to do |
| 5323 | * this; we are not telnet. There are bad interactions between |
| 5324 | * persistent connections and Nagle's algorithm that have very severe |
| 5325 | * performance penalties. (Failing to disable Nagle is not much of a |
| 5326 | * problem with simple HTTP.) |
| 5327 | */ |
| 5328 | rv = apr_socket_opt_set(csd, APR_TCP_NODELAY, 1); |
| 5329 | if (rv != APR_SUCCESS && rv != APR_ENOTIMPL) { |
| 5330 | /* expected cause is that the client disconnected already, |
| 5331 | * hence the debug level |
| 5332 | */ |
| 5333 | ap_log_cerror(APLOG_MARK, APLOG_DEBUG, rv, c, APLOGNO(00139) |
| 5334 | "apr_socket_opt_set(APR_TCP_NODELAY)"); |
| 5335 | } |
| 5336 | |
| 5337 | /* The core filter requires the timeout mode to be set, which |
| 5338 | * incidentally sets the socket to be nonblocking. If this |
| 5339 | * is not initialized correctly, Linux - for example - will |
| 5340 | * be initially blocking, while Solaris will be non blocking |
| 5341 | * and any initial read will fail. |
| 5342 | */ |
| 5343 | rv = apr_socket_timeout_set(csd, c->base_server->timeout); |
| 5344 | if (rv != APR_SUCCESS) { |
| 5345 | /* expected cause is that the client disconnected already */ |
| 5346 | ap_log_cerror(APLOG_MARK, APLOG_DEBUG, rv, c, APLOGNO(00140) |
| 5347 | "apr_socket_timeout_set"); |
| 5348 | } |
| 5349 | |
| 5350 | net->c = c; |
| 5351 | net->in_ctx = NULL; |
| 5352 | net->out_ctx = NULL; |
| 5353 | net->client_socket = csd; |
| 5354 | |
| 5355 | ap_set_core_module_config(net->c->conn_config, csd); |
| 5356 | ap_add_input_filter_handle(ap_core_input_filter_handle, net, NULL, net->c); |
| 5357 | ap_add_output_filter_handle(ap_core_output_filter_handle, net, NULL, net->c); |
| 5358 | return DONE; |
| 5359 | } |
| 5360 | |
| 5361 | AP_DECLARE(int) ap_pre_connection(conn_rec *c, void *csd) |
| 5362 | { |
no test coverage detected