smol-rs / polling

Portable interface to epoll, kqueue, event ports, and wepoll
Apache License 2.0
551 stars 68 forks source link

DRAFT: trying to make add safe #192

Open keepsimple1 opened 8 months ago

keepsimple1 commented 8 months ago

To follow up on the issue #191, I'm experimenting with some changes to make Poller::add safe.

Since I'm new to I/O Safety, I probably missed something or maybe totally wrong. But I wanted to post this PR to get comments and find out what I've missed at least.

This draft change only applied on macOS, i.e. kqueue as I'm trying to see if I was on the right direction. Thanks in advance.

notgull commented 6 months ago

I don't think it's possible to make add safe in the general case; the Windows and poll()-based backends can't be made safe. However it is possible to make it safe for certain backends.

keepsimple1 commented 6 months ago

I don't think it's possible to make add safe in the general case; the Windows

What if we change RawSocket to BorrowedSocket in the following? Will that help? https://github.com/smol-rs/polling/blob/0b4afcaf0a61ee06087d77c490abf8802f91aeff/src/iocp/mod.rs#L174

and poll()-based backends can't be made safe. However it is possible to make it safe for certain backends.

Is it this one? (seems it is still / already safe?) https://github.com/smol-rs/polling/blob/0b4afcaf0a61ee06087d77c490abf8802f91aeff/src/poll.rs#L102