Skip to content
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

Support legacy driver #73

Merged
merged 5 commits into from
May 30, 2022
Merged

Support legacy driver #73

merged 5 commits into from
May 30, 2022

Conversation

ihciah
Copy link
Member

@ihciah ihciah commented May 24, 2022

This PR does many things:

  1. Add legacy driver to support linux without uring and macos.
  2. Add fusion driver to do auto detect and driver selection at runtime.
  3. Better iovec support.
  4. More test cases.
  5. Other optimization.

monoio/src/driver/shared_fd.rs Outdated Show resolved Hide resolved
}
_ => unsafe { std::hint::unreachable_unchecked() },
}
me.index = usize::MAX;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这是为啥

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

返回 Ready 意味着这个 index 已经从 Slab 里删除,标记一下。当 Op Drop 时判断一下就不用从 Slab 里捞了(如果捞的话也捞不到因为是 usize::MAX)。
如果这里不改 index 就不太好标记,下次再捞到的可能是别人的。


let stream = TcpStream::from_shared_fd(completion.data.fd);
// wait write ready
// TODO: not use write to detect writable
let _ = stream.write([]).await;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fd EVFILT_WRITE

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个先 TODO 着吧

@dyxushuai dyxushuai assigned dyxushuai and unassigned dyxushuai May 30, 2022
@dyxushuai dyxushuai self-requested a review May 30, 2022 09:17
// But not all platforms have the `accept4(2)` call. Luckily BSD (derived)
// OSes inherit the non-blocking flag from the listener, so we just have to
// set `CLOEXEC`.
#[cfg(any(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

比较复杂的条件编译可以用宏来包装,也不需要增加额外的 block

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

类似 tokio 的做法

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

目前还好,就 legacy、linux、iouring 几个 feature 组合的情况。这个后面有需求再另开 PR 搞吧。
(当前这个是从 mio fork 出来的代码,具体 syscall 具体分析,不太好复用)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants