Bug 59272 - TCP_DEFER_ACCEPT socket option treated as a toggle, not a timeout
Summary: TCP_DEFER_ACCEPT socket option treated as a toggle, not a timeout
Status: NEW
Alias: None
Product: APR
Classification: Unclassified
Component: APR (show other bugs)
Version: 1.5.2
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: Apache Portable Runtime bugs mailinglist
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-04-04 19:16 UTC by ScottE
Modified: 2016-04-04 19:16 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ScottE 2016-04-04 19:16:57 UTC
For reference, see Bug 41270 for Apache - "TCP_DEFER_ACCEPT timeout set way too low"[1].

The TCP_DEFER_ACCEPT option in APR is treated effectively as a toggle, rather than a timeout, similar to the Apache issue referenced above. Setting a value of "1" effectively tells the kernel to drop sockets if no data is received for a few seconds (not 1 second due to synack_retries). On Linux, this socket option specified a timeout value.

From the tcp(7) manpage for Linux:

  TCP_DEFER_ACCEPT (since Linux 2.4)
    Allow  a  listener  to  be awakened only when data arrives on the socket.
    Takes an integer value (seconds), this can bound the maximum number of
    attempts TCP will make to complete the connection. This option should not be
    used  in code intended to be portable.

In Apache, the value was changed to 30 (seconds) since 2.2.28 and 2.4.x, as a value of 1 can pose issues with load balancers. Although one can clearly turn off this option (deferAccept in Tomcat when using libapr, for example), because it is enabled by default when supported, APR should use a more sensible default value - ideally the same as Apache.

See the Apache bug for additional details, and notes how behavior for Linux is different than BSD.

Relevant code is around line 210 in network_io/unix/sockopt.c.

[1] https://bz.apache.org/bugzilla/show_bug.cgi?id=41270