Skip to content

Commit

Permalink
Release the read lock in a finally block (#703)
Browse files Browse the repository at this point in the history
  • Loading branch information
essobedo authored Oct 16, 2022
1 parent b408dea commit e1e5c08
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -469,14 +469,17 @@ void readInputLoop() {
try {
while (!closing) {
if (readInput.readLock().tryLock(10, TimeUnit.MILLISECONDS)) {
int c = terminal.reader().read(10);
if (c == -1) {
break;
}
if (c == KEY_PLUS || c == KEY_MINUS || c == KEY_CTRL_L || c == KEY_CTRL_M || c == KEY_CTRL_B) {
daemonReceive.accept(Message.keyboardInput((char) c));
try {
int c = terminal.reader().read(10);
if (c == -1) {
break;
}
if (c == KEY_PLUS || c == KEY_MINUS || c == KEY_CTRL_L || c == KEY_CTRL_M || c == KEY_CTRL_B) {
daemonReceive.accept(Message.keyboardInput((char) c));
}
} finally {
readInput.readLock().unlock();
}
readInput.readLock().unlock();
}
}
} catch (InterruptedException e) {
Expand Down

0 comments on commit e1e5c08

Please sign in to comment.