Feature #1447

TCP_DEFER_ACCEPT

Added by admin over 6 years ago. Updated about 5 years ago.

Status:FixedStart date:
Priority:NormalDue date:
Assignee:jan% Done:

100%

Category:core
Target version:1.4.23
Missing in 1.5.x:

Description

Hi,

On Linux, TCP_DEFER_ACCEPT can be enabled to defer accept calls until there is (also) data ready to be read.
On FreeBSD, SO_ACCEPTFILTER can be enabled to defer accept calls until there is a complete HTTP request (or something else) to be read.


#ifdef SO_ACCEPTFILTER
    accept_filter_arg afa;
    bzero(&afa, sizeof(afa));
    strcpy(afa.af_name, "httpready");
    l.setsockopt(SOL_SOCKET, SO_ACCEPTFILTER, &afa, sizeof(afa));
#elif TCP_DEFER_ACCEPT
    int v = true;
    setsockopt(acceptor_.native(), IPPROTO_TCP, TCP_DEFER_ACCEPT, &v, sizeof(v));
#endif

Associated revisions

Revision 2479
Added by stbuehler about 5 years ago

Add option to enable TCP_DEFER_ACCEPT (fixes #1447)

History

#1 Updated by Olaf-van-der-Spek over 5 years ago

  • Target version changed from 1.5.0 to 1.4.21

#2 Updated by icy over 5 years ago

  • Target version changed from 1.4.21 to 1.4.22
  • Patch available set to No

#3 Updated by stbuehler over 5 years ago

  • Target version changed from 1.4.22 to 1.4.23

#4 Updated by stbuehler about 5 years ago

TCP_DEFER_ACCEPT:

Allows 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.

I don't think "TRUE" is a good value here.

#5 Updated by Olaf-van-der-Spek about 5 years ago

You're right, haven't seen that part before. I'm still not sure what exactly that parameter does though.

#6 Updated by stbuehler about 5 years ago

linux kernel sources (net/ipv4/tcp.c), search for TCP_DEFER_ACCEPT:

Translate value in seconds to number of retransmits

I have no idea what that means... :)

0 means disable, so i will make the option a "unsigned short" in the config, and it will be only set if it is != 0.

SO_ACCEPTFILTER is already in the source and enabled by default.

#7 Updated by stbuehler about 5 years ago

  • Status changed from New to Fixed
  • % Done changed from 0 to 100

Applied in changeset r2479.

Also available in: Atom