Commit Graph

248 Commits

Author SHA1 Message Date
John Nunley 1c16a1e4af
v3.6.0
Signed-off-by: John Nunley <dev@notgull.net>
2024-03-23 20:42:01 -07:00
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 50454d1cea
feat: Add support for HermitOS
HermitOS is a microkernel target aiming to provide a simple OS for
virtualized applications. It recently added support for the poll() and
eventfd() system calls, which means we can target it with our poll()
based backend.

Hermit does not have a traditional libc; instead it uses hermit-abi.
However rustix does not support using hermit-abi as its underlying
layer yet. So we have to build a shim layer until it does.

Closes #177
cc bytecodealliance/rustix#1012

Signed-off-by: John Nunley <dev@notgull.net>
2024-03-12 21:33:06 -07:00
John Nunley 634a77c264 bugfix: Remove CallOnDrop from port.rs
CallOnDrop is no longer used in the Windows IOCP backend, and it wasn't
being flagged as unused until the latest nightly. In order to fix
Windows builds, this commit removes CallOnDrop.

Signed-off-by: John Nunley <dev@notgull.net>
2024-03-12 20:46:02 -07:00
John Nunley 4d64fdc572
v3.5.0
Signed-off-by: John Nunley <dev@notgull.net>
2024-02-17 22:02:48 -08:00
John Nunley 77b4ed1156
feat: On RedoxOS, use epoll instead of the poll backend
Technically RedoxOS supports the poll syscall, so we already support
RedoxOS. However, this is very slow. This commit ports this code to
epoll, which should be more efficient.

Closes #176
2024-02-11 08:31:13 -08:00
John Nunley ac7fbcae31
v3.4.0
Signed-off-by: John Nunley <dev@notgull.net>
2024-02-05 19:18:30 -08:00
John Nunley 24e3691794
feat: Add a way to wait on process by PID
This is needed to make processes work in `async-process`.

Signed-off-by: John Nunley <dev@notgull.net>
2024-02-01 06:34:02 -08:00
John Nunley 62430fd56e Annotate ESP-IDF EPERM error with eventfd info
If eventfd isn't initialized, `Polling::new` will fail with an EPERM
error. You need to call the "esp_vfs_eventfd_register" function to
initialize the eventfd subsystem in ESP-IDF. This commit indicates to
the user that this needs to happen.

Signed-off-by: John Nunley <dev@notgull.net>
2024-01-27 21:17:58 -08: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 6125508c93
v3.3.2
Signed-off-by: John Nunley <dev@notgull.net>
2024-01-14 09:00:57 -08:00
John Nunley ea5a38a500
feat(windows): AFD failure now sources underlying I/O error
Previously, if AFD failed to initialize `polling` would return a custom
I/O error with a string error, containing the formatted version of the
underlying system error. However, this means that information about the
underlying system error is lost to the user.

This commit makes it so the returned `io::Error` wraps a user
inaccessible type: `AfdError`. This `AfdError`, when stringified,
returns a similar error message as what was previously returned. In
addition when `.source()` is used it returns the underlying system
error.

Closes #174

Signed-off-by: John Nunley <dev@notgull.net>
2024-01-08 16:34:13 -08:00
John Nunley 1f13664bbb
ci: Add async-io tests back to CI
Closes #145

Signed-off-by: John Nunley <dev@notgull.net>
2024-01-08 08:23:02 -08:00
Taiki Endo 0c794fce50 Ignore dead_code warning for tuple struct
This lint does not take into account destructors.

```
error: field `0` is never read
    --> src\iocp\mod.rs:1155:13
     |
1155 |     Waiting(WaitHandle),
     |     ------- ^^^^^^^^^^
     |     |
     |     field in this variant
     |
     = note: `-D dead-code` implied by `-D warnings`
     = help: to override `-D warnings` add `#[allow(dead_code)]`
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
     |
1155 |     Waiting(()),
     |             ~~
```
2024-01-07 16:11:02 +09:00
Taiki Endo 94c5ebf78b ci: Temporarily disable riscv32imc-esp-espidf build 2024-01-07 16:11:02 +09:00
Taiki Endo e956a8ad64 ci: Update FreeBSD image to 13.2
```
pkg install -y git
Updating FreeBSD repository catalogue...
pkg: http://pkgmir.geo.freebsd.org/FreeBSD:12:amd64/quarterly/meta.txz: Not Found
repository FreeBSD has no meta file, using default settings
pkg: http://pkgmir.geo.freebsd.org/FreeBSD:12:amd64/quarterly/packagesite.pkg: Not Found
pkg: http://pkgmir.geo.freebsd.org/FreeBSD:12:amd64/quarterly/packagesite.txz: Not Found
Unable to update repository FreeBSD
Error updating repositories!
```
2024-01-07 16:11:02 +09:00
Taiki Endo 078c478346 ci: Use cargo-hack's --rust-version flag for msrv check
This respects rust-version field in Cargo.toml, so it removes the need
to manage MSRV in both the CI file and Cargo.toml.
2024-01-07 16:11:02 +09:00
John Nunley b57a7c32a2
v3.3.1
Signed-off-by: John Nunley <dev@notgull.net>
2023-11-24 08:22:27 -08:00
dependabot[bot] 08a316e1fc
m: Update windows-sys requirement from 0.48 to 0.52
* Update windows-sys requirement from 0.48 to 0.52

Updates the requirements on [windows-sys](https://github.com/microsoft/windows-rs) to permit the latest version.
- [Release notes](https://github.com/microsoft/windows-rs/releases)
- [Commits](https://github.com/microsoft/windows-rs/compare/0.48.0...0.52.0)

---
updated-dependencies:
- dependency-name: windows-sys
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* Correct windows-sys imports

Signed-off-by: John Nunley <dev@notgull.net>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: John Nunley <dev@notgull.net>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: John Nunley <dev@notgull.net>
2023-11-24 07:53:04 -08:00
John Nunley 8087787ab2
v3.3.0
Signed-off-by: John Nunley <dev@notgull.net>
2023-10-28 18:54:47 -07:00
John Nunley b9ab821df1
bugfix: Handle interrupts while polling
Previous, `Poller::wait` would bubble signal interruption error to the user.
However, this may be unexpected for simple use cases. Thus, this commit makes
it so, if `ErrorKind::Interrupted` is received by the underlying `wait()` call,
it clears the events and tries to wait again.

This also adds a test for this interruption written by @psychon.

Co-Authored-By: Uli Schlachter <psychon@users.noreply.github.com>
Signed-off-by: John Nunley <dev@notgull.net>
2023-10-27 07:02:08 -07:00
Uli Schlachter 0575cbd4bc
docs: Fix wrong link in docs of Poller::wait()
Once upon a time, this got a Vec as an argument, but that was replaced
with the Events struct. Thus, this should link to Events and not Vec.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2023-10-20 09:49:44 -07:00
Taiki Endo 37a1d4ecd2
Remove needless imports (#159) 2023-10-08 17:23:34 +09:00
Taiki Endo a559165acd
Migrate to Rust 2021 (#158) 2023-10-08 14:46:23 +09:00
tison ceb88a46c4
chore: prefer usize::MAX to std::usize::MAX
Signed-off-by: tison <wander4096@gmail.com>
2023-10-05 20:10:18 -07:00
John Nunley d9a65fdd73
v3.2.0
Signed-off-by: John Nunley <dev@notgull.net>
2023-10-02 07:37:32 -07:00
Al Hoang 99a32b7607
feat: Add support for Haiku OS
Haiku does not support pipe_with at all, so just fall back to pipe().
2023-10-01 20:57:41 -07:00
John Nunley 9e143a38e1
bugfix: Manage sources being inserted into kqueue
Thus far, our kqueue implementation has been a relatively thin layer on
top of the OS kqueue. However, kqueue doesn't keep track of when the
same source is inserted twice, or when a source that doesn't exist is
removed. In the interest of keeping consistent behavior between backends
this commit adds a system for tracking when sources are inserted.

Closes #151

Signed-off-by: John Nunley <dev@notgull.net>
2023-09-27 21:30:46 -07:00
John Nunley 45ebe3b904
v3.1.0
Signed-off-by: John Nunley <dev@notgull.net>
2023-09-25 09:42:41 -07:00
David Hotham 254577da8d
feat: introduce Event::new()
This makes it easier to construct Events.
2023-09-12 06:02:02 -07:00
Taiki Endo 8c99506375 Update actions/checkout action to v4 2023-09-10 18:28:12 +09:00
John Nunley 256542375c
v3.0.0
Signed-off-by: John Nunley <dev@notgull.net>
2023-09-04 18:41:32 -07:00
John Nunley 90c661f5e1 Remove the std default feature
Added in 272bb11eaf for reasons that are
unclear to me. It serves no purpose aside from disabling the API of the
entire crate, so it's best to remove it.

Signed-off-by: John Nunley <dev@notgull.net>
2023-09-04 22:15:28 +02: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
Alex Touchet 792618094c
docs: Fix CI badge and update links
Closes #142
2023-09-04 08:33:22 -07:00
Taiki Endo 9a3fe18981 Use std::os::raw::c_int and remove our own type alias 2023-08-30 02:19:17 +09:00
tison d8595b56a5
feat: Make the constructors for Event const
This allows the Event struct to be used in constants.

Signed-off-by: tison <wander4096@gmail.com>
2023-08-21 18:32:21 -07:00
John Nunley c7cc91a1f1
docs: Specify behavior when registered in multiple pollers
This adds documentation to add() describing what happens when a source
is registered in multiple pollers. A test is also added to ensure this
behavior.

Signed-off-by: John Nunley <dev@notgull.net>
2023-08-16 09:48:14 -07:00
John Nunley 2c279b871c
feat: Add a pipe-based notifier to epoll
In some containers, eventfd is not available as it cannot be implemented
securely in some hosts. This commit adds a fallback notifier that uses
a pipe instead of eventfd.

Closes #122

Signed-off-by: John Nunley <dev@notgull.net>
2023-08-16 08:33:58 -07: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 e42664d57e
m: Remove libc from our dependencies
This means that we only depend on rustix, so all of the system calls
are direct. This should make mustang integration trivial.

Signed-off-by: John Nunley <dev@notgull.net>
2023-08-13 18:49:43 -07:00
John Nunley c6a0890627
feat: Add support for waiting on waitable handles
* Add support for polling waitable handles

* Add a smoke test

* Fix failing tests

* Rebase on latest master

Signed-off-by: John Nunley <dev@notgull.net>

* Update semantics for new system

Signed-off-by: John Nunley <dev@notgull.net>

* Forgot about doctests

Signed-off-by: John Nunley <dev@notgull.net>

---------

Signed-off-by: John Nunley <dev@notgull.net>
2023-08-08 20:40:21 -07:00
ivmarkov 6d13def8ab
Allow pinning Rust nightly to concrete version (#132) 2023-08-07 02:24:30 +09:00
ivmarkov 26afefbbbc
Remove patch.crates-io now that rustix 0.38.7 is out (#131) 2023-08-06 14:58:11 +09:00
John Nunley 49152081d0
Fix failing CI (#130)
- Disable async-io tests for wine
- Fix errant cast in Android

Signed-off-by: John Nunley <dev@notgull.net>
2023-08-05 08:17:53 -07:00
ivmarkov 53793382a7
feat: Support for the ESP-IDF framework
* Support for the ESP-IDF framework

* Restore the spans to work with the raw notify fd

* On Linux eventfd needs PollFlags::IN

* Add cargo check for ESP IDF to the CI

---------

Co-authored-by: imarkov <imarkov@vmware.com>
2023-08-05 07:28:59 -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
John Nunley c86c3894c1
Add smol-rs logo (#127) 2023-07-17 14:30:22 +09:00
dependabot[bot] ea5946c453 Update fastrand requirement from 1.9.0 to 2.0.0
Updates the requirements on [fastrand](https://github.com/smol-rs/fastrand) to permit the latest version.
- [Release notes](https://github.com/smol-rs/fastrand/releases)
- [Changelog](https://github.com/smol-rs/fastrand/blob/master/CHANGELOG.md)
- [Commits](https://github.com/smol-rs/fastrand/compare/v1.9.0...v2.0.0)

---
updated-dependencies:
- dependency-name: fastrand
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-16 19:16:56 +09:00