Skip to content

Commit

Permalink
nixd/lspserver: fix high cpu on fd polling
Browse files Browse the repository at this point in the history
Fixes #627
  • Loading branch information
jduepmeier committed Dec 16, 2024
1 parent f12e2f7 commit 10505ff
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions nixd/lspserver/src/Connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ bool readLine(int fd, const std::atomic<bool> &Close,
if (Close)
return false;

// POLLHUB: hang up from the writer side
// POLLNVAL: invalid request (fd not open)
if (FDs[0].revents & (POLLHUP | POLLNVAL)) {
return false;
}

if (FDs[0].revents & POLLIN) {
ssize_t BytesRead = read(fd, &Ch, 1);
if (BytesRead == -1) {
Expand Down

0 comments on commit 10505ff

Please sign in to comment.