Change epoll polling

1) it is incorrect to call level-triggered epoll in a loop without reading everything
2) it fixes the FIXME
blocking-uring-test
Vitaliy Filippov 2019-12-16 21:37:13 +03:00
parent c7ae3c001c
commit 4fb0579b1b
1 changed files with 52 additions and 52 deletions

18
osd.cpp
View File

@ -107,10 +107,13 @@ void osd_t::loop()
throw std::runtime_error(std::string("epoll failed: ") + strerror(-data->res));
}
handle_epoll_events();
wait_state = 0;
};
wait_state = 1;
}
else if (wait_state == 2)
{
handle_epoll_events();
}
send_replies();
read_requests();
ringloop->submit();
@ -121,12 +124,7 @@ void osd_t::loop()
int osd_t::handle_epoll_events()
{
epoll_event events[MAX_EPOLL_EVENTS];
int count = 0;
int nfds;
// FIXME: We shouldn't probably handle ALL available events, we should sometimes
// yield control to Blockstore and possibly other consumers
while ((nfds = epoll_wait(epoll_fd, events, MAX_EPOLL_EVENTS, 0)) > 0)
{
int nfds = epoll_wait(epoll_fd, events, MAX_EPOLL_EVENTS, 0);
for (int i = 0; i < nfds; i++)
{
if (events[i].data.fd == listen_fd)
@ -175,13 +173,15 @@ int osd_t::handle_epoll_events()
// Mark client as ready (i.e. some data is available)
cl.read_ready = true;
if (!cl.reading)
{
read_ready_clients.push_back(cl.peer_fd);
ringloop->wakeup();
}
}
count++;
}
}
return count;
wait_state = nfds == MAX_EPOLL_EVENTS ? 2 : 0;
return nfds;
}
void osd_t::stop_client(int peer_fd)