GermanCoding / RUDP

A modified version of the RUDP (Reliable UDP) libary originally written by Adrian Granados.
31 stars 15 forks source link

InputStream blocking on close #4

Open SamGinrich opened 4 months ago

SamGinrich commented 4 months ago

Seems, that a read on a socket inputstream is not unblocked, when the local socket instance is closed. Debugging showed that ReliableSocket.shutdownInput(), which notifies the waiting thread, is not called.

Workaround 1) Explicit close on the InputStream

Sequence ReliableSocket.getInputStream.close(); ReliableSocket.close(); would unblock the input stream, though may run into exception as the closed-state of the socket is not properly synchronized

Workaround 2) Modification of RUDP libary

Added the kernel of RealiableSocket.shutdownInput() w/o the throw statements in the asynchronous part of ReliableSocket.closeImpl() https://github.com/GermanCoding/RUDP/blob/master/RUDP/src/net/rudp/ReliableSocket.java, line 1718

This behaves stable, though it's not clear, whether functional requirements hold for other close sequences.

GermanCoding commented 4 months ago

Can you send a PR for 2)?

SamGinrich commented 4 months ago

Here is modified method ReliableSocket.closeImpl() [Sorry for layout]

```

/**