Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce one syscal for fcntl #660

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

theidexisted
Copy link

@theidexisted theidexisted commented Dec 9, 2021

According to the man page: https://man7.org/linux/man-pages/man2/socket.2.html
Since Linux 2.6.27, the type argument serves a second purpose: in
addition to specifying a socket type, it may include the bitwise
OR of any of the following values, to modify the behavior of
socket():

   SOCK_NONBLOCK
          Set the O_NONBLOCK file status flag on the open file
          description (see open(2)) referred to by the new file
          descriptor.  Using this flag saves extra calls to fcntl(2)
          to achieve the same result.

Problem

Minor fix to save one syscall

Solution

Pass the SOCK_NONBLOCK flag via socket

Result

Chances to get better performance.

According to the man page: https://man7.org/linux/man-pages/man2/socket.2.html
       Since Linux 2.6.27, the type argument serves a second purpose: in
       addition to specifying a socket type, it may include the bitwise
       OR of any of the following values, to modify the behavior of
       socket():

       SOCK_NONBLOCK
              Set the O_NONBLOCK file status flag on the open file
              description (see open(2)) referred to by the new file
              descriptor.  Using this flag saves extra calls to fcntl(2)
              to achieve the same result.
@CLAassistant
Copy link

CLAassistant commented Dec 9, 2021

CLA assistant check
All committers have signed the CLA.

@yuerugou54
Copy link

yuerugou54 commented Dec 9, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants