-
Notifications
You must be signed in to change notification settings - Fork 955
Description
There are quite a few places where we call connSetReadHandler and connSetWriteHandler and don't check the return code.
From an API perspective, we only need to check the return code when we're setting the value to a non-null value, which is the only place with known failure modes. The only known failure mode I'm aware of is when you try to set a connection handler to a connection whose fd is greater than the maxclients, which is possible if the ulimit for fds is set greater than the maxclients.
When we fail to check the return code, we might end up in a situation where a connection is not registered and becomes unreachable outside of an operation like client kill. I've seen this at AWS with the primary/replica link, which can lead to a broken link.
I think we have two options:
- Make sure we are better handling these failure modes, as in we always handle the error code when setting the read or write handler.
- Make sure there are no failure modes on the connSetHandler path, by making sure it's a valid connection during connAccept or connConnect. connSetReadHandler and connSetWriteHandler should be changed to a void return type, and panic when they fail. (My preference)