Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSSE: calling SSLSocket.close() should interrupt threads blocked in select()/poll() #246

Merged

Conversation

cconlon
Copy link
Member

@cconlon cconlon commented Jan 1, 2025

This PR adjusts JSSE and lower-level JNI behavior around SSLSocket.close(). When close() is called, it should interrupt any other threads blocked in select()/poll() from read()/write() operations.

This adds a pipe() descriptor which is watched by select()/poll(). That pipe is written to by a thread calling SSLSocket.close() to wake those blocked threads up - preventing a possible deadlock in this scenario.

This pipe() solution is currently only implemented for non-Windows platforms in this PR.

Should fix SunJSSE test: SSLSocketImpl/BlockedAsyncClose.java.

Minor fixes also included in this PR:

  • Add ability to pass CFLAGS to java.sh, ie: CFLAGS="-DTEST_DEFINE" ./java.sh
  • Add GitHub Action test for testing with -DWOLFJNI_USE_IO_SELECT defined (uses select() instead of poll())
  • Update WolfSSLSocketTest TestServer/Client with CountDownLatch for proper Exception detection
  • Fix Visual Studio warning about possible uninitialized pointer variable
  • Remove incorrect ATOMIC_USER define gate around native wolfSSL_GetSide()

@cconlon cconlon self-assigned this Jan 1, 2025
@cconlon cconlon force-pushed the socketCloseInterruptsWriteRead branch 10 times, most recently from 33cfa0e to 0129bfd Compare January 6, 2025 22:37
@cconlon cconlon force-pushed the socketCloseInterruptsWriteRead branch from 0129bfd to 4bc8162 Compare January 20, 2025 20:11
@cconlon cconlon force-pushed the socketCloseInterruptsWriteRead branch from ae8c65e to cd8c49e Compare January 21, 2025 17:20
@JacobBarthelmeh JacobBarthelmeh merged commit d56fa67 into wolfSSL:master Jan 21, 2025
47 checks passed
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.

3 participants