forked from vitalif/vitastor
Change epoll polling
1) it is incorrect to call level-triggered epoll in a loop without reading everything 2) it fixes the FIXMEblocking-uring-test
parent
c7ae3c001c
commit
4fb0579b1b
18
osd.cpp
18
osd.cpp
|
@ -107,10 +107,13 @@ void osd_t::loop()
|
||||||
throw std::runtime_error(std::string("epoll failed: ") + strerror(-data->res));
|
throw std::runtime_error(std::string("epoll failed: ") + strerror(-data->res));
|
||||||
}
|
}
|
||||||
handle_epoll_events();
|
handle_epoll_events();
|
||||||
wait_state = 0;
|
|
||||||
};
|
};
|
||||||
wait_state = 1;
|
wait_state = 1;
|
||||||
}
|
}
|
||||||
|
else if (wait_state == 2)
|
||||||
|
{
|
||||||
|
handle_epoll_events();
|
||||||
|
}
|
||||||
send_replies();
|
send_replies();
|
||||||
read_requests();
|
read_requests();
|
||||||
ringloop->submit();
|
ringloop->submit();
|
||||||
|
@ -121,12 +124,7 @@ void osd_t::loop()
|
||||||
int osd_t::handle_epoll_events()
|
int osd_t::handle_epoll_events()
|
||||||
{
|
{
|
||||||
epoll_event events[MAX_EPOLL_EVENTS];
|
epoll_event events[MAX_EPOLL_EVENTS];
|
||||||
int count = 0;
|
int nfds = epoll_wait(epoll_fd, events, MAX_EPOLL_EVENTS, 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)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < nfds; i++)
|
for (int i = 0; i < nfds; i++)
|
||||||
{
|
{
|
||||||
if (events[i].data.fd == listen_fd)
|
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)
|
// Mark client as ready (i.e. some data is available)
|
||||||
cl.read_ready = true;
|
cl.read_ready = true;
|
||||||
if (!cl.reading)
|
if (!cl.reading)
|
||||||
|
{
|
||||||
read_ready_clients.push_back(cl.peer_fd);
|
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)
|
void osd_t::stop_client(int peer_fd)
|
||||||
|
|
Loading…
Reference in New Issue