Status: WontFix
Owner: trond.norbye
Labels: Type-Defect Priority-Low Maintainability

New issue 85 by trond.norbye: Superfluous calls to fcntl to get/set no-blocking mode
http://code.google.com/p/memcached/issues/detail?id=85

On systems using BSD sockets the socket returned by accept inherits the
properties from the socket you accept from.

Linux implements their socket layer a bit differently by _not_ inheriting
the properties.

We could add an ifdef __linux around the code block, but then we wouldn't
detect new platforms with a similar behavior on accept. The following code
snippet could be used, but it doesn't actually simplify the code.

#ifdef __linux
            /* The socket created by accept() will inherit the properties
             * from c->sfd on systems implementing BSD sockets.
             * The network stack on Linux works differently and doesn't
             * inherit any properties.
             */
            int flags;
            if ((flags = fcntl(sfd, F_GETFL, 0)) < 0 ||
                fcntl(sfd, F_SETFL, flags | O_NONBLOCK) < 0) {
                perror("setting O_NONBLOCK");
                close(sfd);
                break;
            }
#elif !defined(NDEBUG)
            int flags;
            assert((flags = fcntl(sfd, F_GETFL, 0)) != -1 &&
                   (flags & O_NONBLOCK) == O_NONBLOCK);

#endif

I suggest that we leave the code as it is. The primary motivation for
filing the bug was to simplify the code, and this is not part of the
"critical path". You shouldn't be using short-lived connections in the
first place.


--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

Reply via email to