s2n-tls
s2n-tls copied to clipboard
Clarify `S2N_ERR_T_BLOCKED` for blocking sockets
Problem:
It's currently possible for the IO APIs to return a S2N_ERR_T_BLOCKED
error with a blocking socket, which can be confusing for users. This can happen if a timeout is configured on the socket (SO_RCVTIMEO or SO_SNDTIMEO), which elapses before s2n-tls is able read/write. After the timeout has elapsed, the system errno is set to EAGAIN/EWOULDBLOCK, which is how S2N_ERR_T_BLOCKED
is reported:
https://github.com/aws/s2n-tls/blob/670cb43534ee6515033be53369a2af774f3083b0/utils/s2n_io.c#L25-L27
Solution:
Given that errno considers this a blocking error, raising S2N_ERR_T_BLOCKED
is likely the correct behavior. Additionally, without a more specific error from errno, we likely can't give a more specific error since we don't know if the blocking error is due to a timeout or not. However, we should clarify this behavior in our documentation so that users consider the case where a blocking socket returns a blocked error.