Skip to content

Fix read stall on TLS streams with non-select drivers - #117

Open
kafkiansky wants to merge 1 commit into
amphp:2.xfrom
kafkiansky:fix/tls-feof-pending-data
Open

kafkiansky wants to merge 1 commit into
amphp:2.xfrom
kafkiansky:fix/tls-feof-pending-data

Conversation

@kafkiansky

Copy link
Copy Markdown

On a TLS stream feof() checks liveness with SSL_peek(), which moves a record that has just arrived from the socket into the OpenSSL buffer. If that happens between the empty direct read and enabling the watcher, the socket is no longer readable and drivers polling the descriptor (uv, ev, event) never invoke the watcher, so the read waits forever although the data is buffered. StreamSelectDriver is not affected because stream_select() checks SSL_pending().

Read once more after feof() reports the stream is still open.

On a TLS stream feof() checks liveness with SSL_peek(), which moves a record
that has just arrived from the socket into the OpenSSL buffer. If that happens
between the empty direct read and enabling the watcher, the socket is no
longer readable and drivers polling the descriptor (uv, ev, event) never
invoke the watcher, so the read waits forever although the data is buffered.
StreamSelectDriver is not affected because stream_select() checks
SSL_pending().

Read once more after feof() reports the stream is still open.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant