alibaba / PhotonLibOS

Probably the fastest coroutine lib in the world!

Home Page:https://PhotonLibOS.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

-

beef9999 opened this issue · comments

POC:

Set up a socket client with multiple threads, each of the threads establishing a connection to a server. (Not using pooled-socket.)

In each send/recv, we would use wait_for_fd to do one-shot poll, and the underlying method is add_interest.

The error occurs at line 127.

PhotonLibOS/io/epoll.cpp

Lines 114 to 129 in 87d0bae

virtual int add_interest(Event e) override {
if (e.fd < 0)
LOG_ERROR_RETURN(EINVAL, -1, "invalid file descriptor ", e.fd);
if ((size_t)e.fd >= _inflight_events.size())
_inflight_events.resize(e.fd * 2);
auto& entry = _inflight_events[e.fd];
if (e.interests & entry.interests) {
if (((e.interests & entry.interests & EVENT_READ) &&
(entry.reader_data != e.data)) ||
((e.interests & entry.interests & EVENT_WRITE) &&
(entry.writer_data != e.data)) ||
((e.interests & entry.interests & EVENT_ERROR) &&
(entry.error_data != e.data))) {
LOG_ERROR_RETURN(EALREADY, -1, "conflicted interest(s)");
}
}

Below is a POC you can verify:

Client: ./net-perf -client -ip 10.144.106.75 -client_thread_num 8
Server: ./net-perf

https://github.com/beef9999/PhotonLibOS/blob/beef9999/poc-conflicted-interest/examples/perf/net-perf.cpp

io_uring engine doesn't have this problem