Bug 196061 - setsockopt(s,IPPROTO_TCP,TCP_NODELAY,...) returns -1 && errno == 0
Summary: setsockopt(s,IPPROTO_TCP,TCP_NODELAY,...) returns -1 && errno == 0
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 10.0-RELEASE
Hardware: amd64 Any
: --- Affects Many People
Assignee: freebsd-bugs mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-17 13:45 UTC by Warren Gay
Modified: 2015-11-24 09:53 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Warren Gay 2014-12-17 13:45:53 UTC
setsockopt(s,IPPROTO_TCP,TCP_NODELAY,...) returns -1 as if it has failed, but errno == 0. This occurs on an IPv4 socket, newly accepted by:

   accept4(...,SOCK_NONBLOCK|SOCK_CLOEXEC);

It appears that the setsockopt() call has succeeded because there seems to be some improvement in the http server performance after the call.
Comment 1 Marián Černý 2015-11-24 09:53:38 UTC
This is probably not be related.

On FreeBSD 9.3 it returns -1 and errno=22 (EINVAL) for me in passenger:

Ser/Server.h:655: [ApiServer] Cannot disable Nagle's algorithm on a TCP socket: Invalid argument (errno=22)

    if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &flag, sizeof(int)) == -1
     && errno != ENOPROTOOPT
     && errno != ENOTSUP
     && errno != EXTENSION_EOPNOTSUPP)
    {
        int e = errno;
        SKS_WARN("Cannot disable Nagle's algorithm on a TCP socket: " <<
            strerror(e) << " (errno=" << e << ")");
    }