Skip to content

Commit 941f093

Browse files
Avoid blocking on redundant POSIX bump writes.
Skip the notify-pipe write when a wake byte is already pending, retry on EINTR, and generalise the Windows WSASetEvent error message. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent b8df3da commit 941f093

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

src/extension/IOController_Posix.ipp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,18 @@ namespace extension {
146146
}
147147

148148
void IOController::bump() const {
149+
pollfd pfd{notifier.recv, POLLIN, 0};
150+
if (::poll(&pfd, 1, 0) > 0 && (pfd.revents & POLLIN) != 0) {
151+
return;
152+
}
153+
149154
uint8_t val = 1;
150-
if (::write(notifier.send, &val, sizeof(val)) < 0) {
155+
ssize_t written = 0;
156+
do {
157+
written = ::write(notifier.send, &val, sizeof(val));
158+
} while (written < 0 && network_errno == EINTR);
159+
160+
if (written < 0) {
151161
throw std::system_error(network_errno,
152162
std::system_category(),
153163
"There was an error while writing to the notification pipe");

src/extension/IOController_Windows.ipp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ namespace extension {
129129
if (!WSASetEvent(notifier.notifier)) {
130130
throw std::system_error(WSAGetLastError(),
131131
std::system_category(),
132-
"WSASetEvent() for configure io reaction failed");
132+
"WSASetEvent() for IOController notifier failed");
133133
}
134134
}
135135

0 commit comments

Comments
 (0)