Commit Graph

13 Commits

Author SHA1 Message Date
irvingouj @ Devolutions e25b3b4e4c
feat: Replace is_connect_failed with is_err
In linux, epoll, EPOLLHUP may happen even if no connection call is made. It
would confuse callers for what is actually happening.

Replaced is_connect_failed, and we detect if connection failed by using the
combination of is_err and is_interrupt, please see the example, tcp_client
2024-03-20 22:04:46 -07:00
John Nunley ae484a0a12 tests: Fix clippy error in wait-signal
Signed-off-by: John Nunley <dev@notgull.net>
2024-01-27 21:17:58 -08:00
irvingouj @ Devolutions cf25dd85f8
feat: Add the ability to identify if the connection has failed 2024-01-26 12:58:39 -08:00
John Nunley 7718565d11
Remove libc from dev deps (#146)
Signed-off-by: John Nunley <dev@notgull.net>
Signed-off-by: Alain Zscheile <fogti+devel@ytrizja.de>
2023-09-04 22:12:42 +02:00
John Nunley a521cd2c29
breaking: Extract the Events struct and make the Event struct opaque
* Add better documentation for the IOCP module

* Extract Events from Poller

This prevents the need to have an intermediate buffer to read events
from, reducing the need for an allocation and a copy. This is a breaking
change.

* Add event extra information

Foundation for more details later on.

* Add PRI and HUP events
* Fix various failing tests

- Make sure that waitable handles interact properly with the new
  infrastructure
- Fix failing doctests

* Review comments

- Make set_* take a boolean for the value of the flag
- Make Events !Sync
- Fix visibility modifiers
- Inline more methods
- Use a better strategy for testing

* Move completion packets into the Events buffer

This removes one of the mutexes that we have to lock.

* Review comments

Signed-off-by: John Nunley <dev@notgull.net>
2023-08-14 10:03:20 -07:00
John Nunley 6eb7679aa3
breaking: Rework the API for I/O safety
* Rework the API for I/O safety

* Bump to rustix v0.38
2023-08-03 20:15:59 -07:00
Ivan Zvonimir Horvat e161698e6c
114: Examples; add nc message in 2 listeners (#115) 2023-05-31 08:50:27 -07:00
John Nunley a5aae98805
feat: Expose other kqueue filters (#83)
* feat: Expose other kqueue filters

* Fix netbsd/openbsd compilation

* Build MSRV for FreeBsd/OpenBsd in CI

* Only run MSRV BSD builds on Linux

* Change API a little + fix netbsd timer

* Add inlines + move PollerSealed

* rustfmt

* Make filter fields public

* Fix examples
2023-02-03 11:14:33 -08:00
Stjepan Glavina 0a299cf060 Small cleanup 2020-10-02 17:34:53 +02:00
Yorick Peterse ba05307af1
Separate adding and modifying of file descriptors
This replaces Poller.insert() and Poller.interest() with Poller.add()
and Poller.modify(), and renames Poller.remove() to Poller.delete().

The method Poller.add() is used for adding a new file descriptor, while
Poller.modify() is used for updating an existing one. Poller.remove() is
renamed to Poller.delete() so the naming scheme of these methods follows
that of epoll, wepoll, etc.

This new setup means that adding a new socket only requires a single
call of Poller.add(), instead of a combination of Poller.insert() and
Poller.interest(). This reduces the amount of system calls necessary,
and leads to a more pleasant API.

On systems that use kqueue or ports, the behaviour of Poller.add() and
Poller.modify() is the same. This is because on these systems adding an
already existing file descriptor will just update its configuration.
This however is an implementation detail and should not be relied upon
by users.

Migrating to this new API is pretty simple, simply replace this:

    poller.insert(&socket);
    poller.interest(&socket, event);

With this:

    poller.add(&socket, event);

And for cases where Poller.interest() was used for updating an existing
file descriptor, simply replace it will a call to Poller.modify().

See https://github.com/stjepang/polling/issues/16 and
https://github.com/stjepang/polling/pull/17 for more information.
2020-10-01 21:50:59 +02:00
Yorick Peterse 4e5c3ce836
Don't automatically make descriptors non-blocking
This adds redundant system call overhead for file descriptors which have
already been turned into non-blocking file descriptors. In addition, the
polling crate doesn't need to implement platform specific code for
enabling non-blocking mode. Instead, users of polling can do so using
(for example) standard library methods such as
TcpListener.set_nonblocking().

See https://github.com/stjepang/polling/issues/16 for more information.
2020-10-01 20:06:07 +02:00
Stjepan Glavina 08745b5c50 Document non-blocking mode 2020-08-08 10:20:19 +02:00
Stjepan Glavina 5b32dd8e82 Initial commit 2020-08-06 15:05:24 +02:00