161 Commits

Author SHA1 Message Date
Thomas de Zeeuw b3acb4133c Add Interest::PRIORITY
To trigger Event::is_priority on Linux and Android.

In the future we might want to include EV_OOBAND for kqueue, but that
seems to be Apple only (FreeBSD and OpenBSD don't implement it at
least).

Co-authored-by: Lars Pöschel <lars.poeschel@edag.com>
2023-02-14 11:46:03 +01:00
Thomas de Zeeuw 512744772f Use consistent cfg attributes 2023-02-13 19:20:11 +01:00
Thomas de Zeeuw fda0b947b1 Fix Clippy warnings
Don't agree with the `&path` -> `path`, but it's fine.
2022-11-30 16:07:41 +00:00
Alexis (Poliorcetics) Bourget 618ac9a378 deps: update to windows-sys 0.42.0 2022-10-22 19:29:48 +00:00
Thomas de Zeeuw 35aa5580a5 Fix clippy warnings (#1617) 2022-09-05 11:05:17 +02:00
Jake Shadle 527db2e976 Replace winapi/ntapi with windows-sys
This updates miow to 0.4, which now uses the windows-sys crate instead
of winapi, as the former is maintained and updated frequently as opposed
to winapi. The windows-sys crate also covers more of the Windows API
surface, which also allowed me to remove the dependency on ntapi (as it
still depends on winapi). There was only a single function,
`NtCancelIoFileEx` that was present in ntapi but not windows-sys, so I
merely added the extern declaration in the one place it was used as it
is not worth bringing in a dependency just for that.
2022-03-31 10:34:52 +02:00
Harald Hoyer fff06a064b Disable all tests, which don't pass for target_os = "wasi"
Signed-off-by: Harald Hoyer <harald@profian.com>
2022-03-08 20:27:18 +01:00
Thomas de Zeeuw ccb07ee209 Fix feature flags for some tests files
The test util module requires both the "os-poll" and "net" features.
2021-11-07 19:42:00 +01:00
Thomas de Zeeuw 31913f4e72 Remove cfg attributes for Solaris
We never really supported Solaris, we pretended it implemented epoll,
but it never did see https://github.com/tokio-rs/mio/issues/1152. As no
one ever committed to being a maintainer for the port I'm removing it
now with this commit.

Instead replace it with illumuos on the CI, which we do support (as it
supports epoll) and for which we do have maintainers.
2021-11-07 19:42:00 +01:00
Ben Noordhuis 597f6c436d Add sys::unix::SocketAddr::as_abstract_namespace()
Fixes #1517.
2021-10-16 16:33:35 +02:00
Thomas de Zeeuw 754edfb56f Fix Clippy warnings on Windows
Seems this isn't check on the CI.
2021-10-08 13:17:03 +02:00
Thomas de Zeeuw 0207bc6bd7 Fix Clippy warnings 2021-10-08 13:17:03 +02:00
Thomas de Zeeuw cd223b6ea8 Remove TcpSocket type
The socket2 crate provide all the functionality and more. Furthermore
supporting all socket options is beyond the scope of Mio.

The easier migration is to the socket2 crate, using the Socket or
SockRef types.

The migration for Tokio is tracked in
https://github.com/tokio-rs/tokio/issues/4135.
2021-10-08 13:17:03 +02:00
Thomas de Zeeuw 84393bbff8 Change port in connect_error
Hopefully this port is actually not used.

Also check Event::is_write_closed since we expect that to be true.
2021-07-03 17:06:27 +02:00
Ivan Enderlin 6a5e2299e2 chore: Make Clippy happy (bis). 2021-06-26 23:29:02 +02:00
Ivan Enderlin fe49ca5c30 chore: Make Clippy happy. 2021-06-26 23:29:02 +02:00
Thomas de Zeeuw 365fa2085f Remove unsound offset_of macro
And replace it with constants that define the offsets to the fields.
It's not a pretty solution, but it's one without UB.
2021-05-13 15:22:27 +00:00
Rob Ede e8abccf445 use unspecified wording in some docs 2021-04-01 16:10:05 +00:00
Ivan Enderlin 6c4c099f18 test: Fix usage of panic!. 2021-03-30 12:01:00 +00:00
AIkorsky dee260af65 Fix error handling in NamedPipe::write 2021-02-22 21:12:36 +00:00
Thomas de Zeeuw de0c67da32 Remove unusual byte groupings
Clippy was complaining about this.
2021-01-05 15:25:33 +00:00
Thomas de Zeeuw 771c9f9ccb Forget socket in set_linger_zero
Since we pass a reference to the socket we don't own it, so we should
forget it not drop it.

Fixes #1421.
2020-12-30 15:33:59 +00:00
Thomas de Zeeuw 10f4cf9687 Mark UdpSocket assert_size test as a test
Didn't have the #[test] attribute.
2020-12-30 15:33:59 +00:00
Thomas de Zeeuw e24dc2fe06 Deflake connect_error test
By making it less strict, removing the expect_no_events call.

Fixes #1332.
2020-12-30 15:33:59 +00:00
Joshua M. Clulow 2effb144eb ignore tcp_shutdown_client_both_close_event failure on illumos
At present, is_write_closed() does not appear to be true on the event
that fires after shutdown() is called.  There is already a similar gag
for the tcp_shutdown_client_write_close_event test, so add one here for
now.  When support for the native illumos "event ports" polling
mechanism is added, to replace the use of epoll emulation, this can be
revisted.
2020-12-08 09:53:45 +00:00
Thomas de Zeeuw 94d143be5c Use util functions in unix_pipe tests 2020-12-03 10:16:46 +00:00
Thomas de Zeeuw 25cc7e8650 Fix underflow in socketAddr::address
With a regression test for issue #1403.
2020-12-01 20:36:53 +00:00
Alan Somers 36daa5d142 Add smoke tests for POSIX AIO
Fixes #1054
2020-12-01 18:54:17 +00:00
Thomas de Zeeuw 6b726d96f7 Remove the requirement to enable all features for testing 2020-11-13 11:36:37 +00:00
Thomas de Zeeuw 962ee39c59 Update tests to use new features
udp, tcp, uds -> net.
pipie -> os-ext.
2020-11-13 11:36:37 +00:00
Thomas de Zeeuw ea6a0baba4 Move assert_size test to UDP and TCP tests
One less binary and less verbose output about running a single test.
2020-11-13 11:36:37 +00:00
Kevin Leimkuhler 8f4f5c6d27 Add UDP test sending empty data
Other discussion: https://github.com/nodejs/node/issues/30030

Signed-off-by: Kevin Leimkuhler <kevin@kleimkuhler.com>
2020-11-13 11:15:08 +00:00
Eliza Weisman 419fa50f3d net: add keepalive support to TcpSocket
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2020-11-11 10:13:29 +00:00
Zeki Sherif 3bca62a73c Support setting SO_LINGER 2020-11-06 16:51:32 +00:00
Eliza Weisman d7e6b81829 net: add TcpSocket::set_{send, recv}_buffer_size (#1384)
This commit adds methods for setting `SO_RECVBUF` and `SO_SNDBUF` to
Mio's `TcpSocket` type. It would be nice to eventually expose these in
Tokio, so adding them to Mio is the first step. 

See tokio-rs/tokio#3082 for details.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2020-11-02 10:15:04 -08:00
Zeki Sherif cbbdb09f94 Add getter for local_addr on TcpSocket (#1379) 2020-10-29 10:35:40 -07:00
Zeki Sherif 6a95b2d579 Add SO_REUSEPORT support for TCP socket (#1375) 2020-10-24 10:12:53 -07:00
Thomas de Zeeuw c28423a07d Add unix::pipe (#1356)
Adds one new function: unix::pipe, which is a wrapper around the pipe(2)
system call, and two new types: Sender and Receiver, wrappers around the
file descriptors.

This is a port of https://github.com/Thomasdezeeuw/mio-pipe, commit
8c3025edf128e90733e95327d88493887b93fcdd.
2020-10-24 10:12:37 -07:00
Thomas de Zeeuw 0b12528d87 Add more registering tests (#1360) 2020-10-24 10:11:39 -07:00
Thomas de Zeeuw c4f1142c1c Add a check that a single Waker is active per Poll instance (#1329) 2020-10-24 10:11:04 -07:00
Marc-Antoine Perennou 875e8155d7 tests: cleanup set_linger_zero
Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
2020-10-22 08:16:38 +00:00
Marc-Antoine Perennou b4a81726d5 tests: rename, add comment
Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
2020-10-22 08:16:38 +00:00
Marc-Antoine Perennou dabf68390d tests: use our own TcpSocket instead of socket2
Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
2020-10-22 08:16:38 +00:00
Carl Lerche 4726a8cecc Fix HUP notifications on windows (#1370) 2020-10-19 15:34:46 -07:00
Marc-Antoine Perennou a2b0024c4e tests: don't restrict connection_reset_by_peer to unix
Now that we use our own TcpSocket, we can run this on windows too

Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
2020-10-14 14:26:49 +00:00
Marc-Antoine Perennou e00a9cbd44 tests: drop net2 usage
Use our own TcpSocket instead

Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
2020-10-14 14:26:49 +00:00
Carl Lerche c27ce39ec2 Add TcpSocket, a basic TCP socket builder (#1358)
This provides `TcpSocket`, a basic API for building a TCP socket. The
goal is not to provide comprehensive coverage of all system options, but
to provide an API for the most common cases.

This is added now as a replacement for the removal of
`TcpStream::connect_std`. The `connect_std` function from v0.6 was used
until now as the strategy to set socket option before obtaining a mio
TcpStream.

Providing some strategy for customizing a `TcpStream` is required for
Hyper to be able to upgrade.
2020-10-06 12:30:36 -07:00
Carl Lerche fbf6fb329a Add windows NamedPipe (#1351)
Adds a NamedPipe implementation for windows. It is based on the IOCP API. To
bridge the IOCP model with the readiness model, buffers are maintained
internally. Writes are first written to the internal buffer and the buffer is submitted
to IOCP. The internal read buffer is submitted to IOCP to be filled. Once it is filled
the pipe becomes ready and the user can read from it.
2020-10-01 20:31:22 -07:00
Thomas de Zeeuw 1323196e5a Fix Clippy complaining about single-character names 2020-06-29 12:52:21 +00:00
Geoffry Song 3b7aa1018a tcp_reset_close_event: work around flake 2020-05-20 11:35:42 +00:00