Skip to content

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

@stefanmh

Description

@stefanmh

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions