Problem is that in recent kernels io_uring may return completions BEFORE clearing the submission queue. I.e. for example its capacity is 512, there were 512 requests, one of them completed, so when the request completion is processed the queue "should have" 1 free slot. But sometimes it doesn't because io_uring doesn't always clear the submission queue before sending CQE :-/
26 lines
592 B
C++
26 lines
592 B
C++
// Copyright (c) Vitaliy Filippov, 2019+
|
|
// License: VNPL-1.1 or GNU GPL-2.0+ (see README.md for details)
|
|
|
|
#pragma once
|
|
|
|
#include <map>
|
|
|
|
#include "ringloop.h"
|
|
#include "timerfd_manager.h"
|
|
|
|
class epoll_manager_t
|
|
{
|
|
int epoll_fd;
|
|
bool pending;
|
|
ring_consumer_t consumer;
|
|
ring_loop_t *ringloop;
|
|
std::map<int, std::function<void(int, int)>> epoll_handlers;
|
|
public:
|
|
epoll_manager_t(ring_loop_t *ringloop);
|
|
~epoll_manager_t();
|
|
void set_fd_handler(int fd, bool wr, std::function<void(int, int)> handler);
|
|
void handle_epoll_events();
|
|
|
|
timerfd_manager_t *tfd;
|
|
};
|