Skip to content

net.mbedtls: have shutdown close accepted connections too - #19164

Merged
medvednikov merged 1 commit into
vlang:masterfrom
jameskirkwood:mbedtls_disconnect_clients
Aug 30, 2023
Merged

medvednikov merged 1 commit into
vlang:masterfrom
jameskirkwood:mbedtls_disconnect_clients

Conversation

@jameskirkwood

Copy link
Copy Markdown
Contributor

This PR changes (SSLListener) accept() in vlib/net/mbedtls/ssl_connection.v so that the client connection socket it creates will be closed by (SSLConn) shutdown().

Without this change, shutdown() does not close connections created by accept() and clients that are designed to keep receiving (or sending) data until the server closes the connection will be left to time out. This makes it difficult to implement the Gemini protocol, for example.

@spytheman

Copy link
Copy Markdown
Contributor

Can you add a small test please?

@jameskirkwood

Copy link
Copy Markdown
Contributor Author

Can you add a small test please?

Sure.

I'm new to the code base and language -- Would it be appropriate to rename the existing test file mbedtls_sslconn_shutdown_does_not_panic_test.v to be less specific and add a new test_ function to it? If so, should it be mbedtls_test.v, ssl_listener_test.v or ssl_connection_test.v? Alternatively I suppose I might create that file without touching mbedtls_sslconn_shutdown_does_not_panic_test.v. I would like to avoid duplicating the test server config though.

@spytheman

Copy link
Copy Markdown
Contributor

You can rename it to mbedtls_test.v, then add a fn test_shutdown_closes_accepted_connections() { in it.

@trufae

trufae commented Aug 29, 2023

Copy link
Copy Markdown
Contributor

i can confirm this patch fixes the issue πŸ‘

@medvednikov

Copy link
Copy Markdown
Member

It's an important fix, I'll merge it for now without a test.

@medvednikov
medvednikov merged commit 7927583 into vlang:master Aug 30, 2023
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

Successfully merging this pull request may close these issues.

4 participants