diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/core_filters.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/server/core_filters.c b/server/core_filters.c index c0275dc0de..0f7a093a3a 100644 --- a/server/core_filters.c +++ b/server/core_filters.c @@ -493,6 +493,18 @@ static void delete_meta_bucket(apr_bucket *bucket) apr_bucket_delete(bucket); } +static APR_INLINE void sock_nopush(apr_socket_t *s, int to) +{ + /* Disable TCP_NOPUSH handling on OSX since unsetting it won't push + * retained data, which might introduce delays if further data don't + * come soon enough or cause the last chunk to be sent only when the + * connection is shutdown (e.g. after KeepAliveTimeout). + */ +#if APR_TCP_NOPUSH_FLAG && !defined(__APPLE__) + (void)apr_socket_opt_set(s, APR_TCP_NOPUSH, to); +#endif +} + static apr_status_t send_brigade_nonblocking(apr_socket_t *s, apr_bucket_brigade *bb, core_output_ctx_t *ctx, @@ -514,7 +526,7 @@ static apr_status_t send_brigade_nonblocking(apr_socket_t *s, #if APR_HAS_SENDFILE if (can_sendfile_bucket(bucket)) { if (nvec > 0) { - (void)apr_socket_opt_set(s, APR_TCP_NOPUSH, 1); + sock_nopush(s, 1); rv = writev_nonblocking(s, bb, ctx, nbytes, nvec, c); if (rv != APR_SUCCESS) { goto cleanup; @@ -544,7 +556,7 @@ static apr_status_t send_brigade_nonblocking(apr_socket_t *s, nbytes = 0; nvec = 0; } - (void)apr_socket_opt_set(s, APR_TCP_NOPUSH, 0); + sock_nopush(s, 0); rv = apr_bucket_read(bucket, &data, &length, APR_BLOCK_READ); } @@ -572,7 +584,7 @@ static apr_status_t send_brigade_nonblocking(apr_socket_t *s, /* Make sure that these new data fit in our iovec. */ if (nvec == ctx->nvec) { if (nvec == NVEC_MAX) { - (void)apr_socket_opt_set(s, APR_TCP_NOPUSH, 1); + sock_nopush(s, 1); rv = writev_nonblocking(s, bb, ctx, nbytes, nvec, c); if (rv != APR_SUCCESS) { goto cleanup; @@ -610,7 +622,7 @@ static apr_status_t send_brigade_nonblocking(apr_socket_t *s, if (nbytes > sconf->flush_max_threshold && next != APR_BRIGADE_SENTINEL(bb) && next->length && !is_in_memory_bucket(next)) { - (void)apr_socket_opt_set(s, APR_TCP_NOPUSH, 1); + sock_nopush(s, 1); rv = writev_nonblocking(s, bb, ctx, nbytes, nvec, c); if (rv != APR_SUCCESS) { goto cleanup; @@ -624,7 +636,7 @@ static apr_status_t send_brigade_nonblocking(apr_socket_t *s, } cleanup: - (void)apr_socket_opt_set(s, APR_TCP_NOPUSH, 0); + sock_nopush(s, 0); return rv; } |