Skip to content

Commit

Permalink
Cancel channel key on end of stream
Browse files Browse the repository at this point in the history
  • Loading branch information
seime committed Jul 22, 2024
1 parent e4adc6a commit b1b703a
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void start() {
logger.debug("Starting selector thread");
while (keepRunning) {
try {
selector.select(1000);
selector.select(10000);
// token representing the registration of a SelectableChannel with a Selector
Set<SelectionKey> keys = selector.selectedKeys();
logger.trace("Selected keys: {}", keys.size());
Expand Down Expand Up @@ -68,6 +68,7 @@ private void processKey(SelectionKey readyKey) {
int read = channel.read(buffer);
if (read == -1) {
logger.debug("End of stream, closing");
channel.keyFor(selector).cancel();
frameHelper.endOfStream();
} else {
if (read == READ_BUFFER_SIZE) {
Expand Down

0 comments on commit b1b703a

Please sign in to comment.