Skip to content

[lldb] [debugserver] Handle interrupted reads correctly #84872

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions lldb/tools/debugserver/source/RNBSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,13 @@ rnb_err_t RNBSocket::Listen(const char *listen_host, uint16_t port,
while (!accept_connection) {

struct kevent event_list[4];
int num_events =
kevent(queue_id, events.data(), events.size(), event_list, 4, NULL);
int num_events;
do {
errno = 0;
num_events =
kevent(queue_id, events.data(), events.size(), event_list, 4, NULL);
} while (num_events == -1 &&
(errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR));

if (num_events < 0) {
err.SetError(errno, DNBError::MachKernel);
Expand Down Expand Up @@ -291,7 +296,12 @@ rnb_err_t RNBSocket::Read(std::string &p) {
// DNBLogThreadedIf(LOG_RNB_COMM, "%8u RNBSocket::%s calling read()",
// (uint32_t)m_timer.ElapsedMicroSeconds(true), __FUNCTION__);
DNBError err;
ssize_t bytesread = read(m_fd, buf, sizeof(buf));
ssize_t bytesread;
do {
errno = 0;
bytesread = read(m_fd, buf, sizeof(buf));
} while (bytesread == -1 &&
(errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR));
if (bytesread <= 0)
err.SetError(errno, DNBError::POSIX);
else
Expand Down