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

Fix re-used connections after fork (again) #863

Closed
stefanmh opened this issue May 26, 2017 · 3 comments
Closed

Fix re-used connections after fork (again) #863

stefanmh opened this issue May 26, 2017 · 3 comments

Comments

@stefanmh
Copy link

When fork()ing a process having a Redis object, the child inherits the file descriptors.
To prevent a race, the child correctly refuses to use the inherited connections (see b8dd224). It thus calls close() on those fd-s (good), but also shutdown() (bad), thus breaking the socket for the parent.

See e.g. http://www.unixguide.net/network/socketfaq/2.6.shtml:

Generally the difference between close() and shutdown() is: close()
closes the socket id for the process but the connection is still
opened if another process shares this socket id. The connection stays
opened both for read and write, and sometimes this is very important.
shutdown() breaks the connection for all processes sharing the socket
id. Those who try to read will detect EOF, and those who try to write
will reseive SIGPIPE, possibly delayed while the kernel socket buffer
will be filled.

@rolette
Copy link

rolette commented Sep 15, 2017

Same issues as #732. I submitted a fix for it (#784) that we've been running for months, but it hasn't been merged in.

@andymccurdy
Copy link
Contributor

This is now resolved. Sorry for the amount of time that it took.

@andymccurdy
Copy link
Contributor

3.2.0 has been released with these fixes.

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

No branches or pull requests

3 participants