Commit Graph

588 Commits

Author SHA1 Message Date
Carl Lerche
19d5ebe61c misc cleanup
* split up TCP files into stream / listener
* organize import order
* split up misc other files
2019-08-27 18:44:28 +00:00
Thomas de Zeeuw
3550494f0b Use consistent use statement order 2019-08-23 10:16:30 +00:00
Thomas de Zeeuw
72a001a8e3 Use Selector::try_clone in kqueue::Waker
Removing the special Selector::try_clone_waker method.
2019-08-23 10:16:30 +00:00
PerfectLaugh
e054a7d587 Fix issue in #1062 2019-08-21 12:21:47 +00:00
PerfectLaugh
4276d071e3 Reverts two issues
This reverts commit 9dc562ca0f9c2a260a3e2e953a5a636103d8a903.
2019-08-21 11:26:00 +00:00
PerfectLaugh
d07989a3b8 Make is_read_hup detects AFD_POLL_DISCONNECT 2019-08-21 11:26:00 +00:00
PerfectLaugh
d7fa70644f Fix udp issue in #1062 2019-08-21 11:26:00 +00:00
PerfectLaugh
588e808576 Changed as requested 2019-08-21 11:26:00 +00:00
PerfectLaugh
1dd6000a6d Recover non-blocking connect and bind 2019-08-21 11:26:00 +00:00
PerfectLaugh
2653117b84 Fix several flags handling 2019-08-21 11:26:00 +00:00
PerfectLaugh
5de1317418 Refactored InternalState, improved select timeout handling and AFD flags fixes 2019-08-21 11:26:00 +00:00
PerfectLaugh
bbc2f774c9 Improve afd_group locks 2019-08-21 11:26:00 +00:00
PerfectLaugh
6b810629c3 Changes RefCell to UnsafeCell 2019-08-21 11:26:00 +00:00
PerfectLaugh
c6d88a5810 Fix for https://github.com/tokio-rs/mio/issues/1041#issuecomment-519674615 2019-08-21 11:26:00 +00:00
PerfectLaugh
8e0b0364ab Temporary fix for https://github.com/tokio-rs/mio/issues/1041#issuecomment-519674615 2019-08-21 11:26:00 +00:00
Thomas de Zeeuw
3626fdd2e5 Rename Interests::and to Interests::add 2019-08-20 16:45:33 +00:00
Thomas de Zeeuw
ce66285747 Make Interests::is_* methods constant 2019-08-20 16:45:33 +00:00
Thomas de Zeeuw
7f7c62de8d Add Interests::and
This allows adding two interests together, much like the BitOr
implementation, but is a constant function.
2019-08-20 16:45:33 +00:00
Thomas de Zeeuw
eee0a9f10a Small cleanups in poll module
Also fixes a small type-o.
2019-08-19 19:09:36 +00:00
Thomas de Zeeuw
59443cd224 Remove poll interruptible (#1056)
Poll::poll is changed to not retry the system call if is its
interrupted.

Removes Poll::poll_interruptible as Poll::poll now does this.
2019-08-19 08:18:49 -07:00
Thomas de Zeeuw
200aaa7a2c Remove repr(transparent) from Registry and Poll
It is no longer needed.
2019-08-13 22:30:56 +00:00
Thomas de Zeeuw
6072de2b84 Remove Deref<Registry> from Poll
And revert back to using Poll::registry.
2019-08-13 22:30:56 +00:00
Thomas de Zeeuw
14c049b923 Remove Arc from Poll and Registry
And add back register, register and register to Poll.
2019-08-13 22:30:56 +00:00
Thomas de Zeeuw
f30debef5c Remove net2 dependency (#1029)
Removing the need for the net2 crate.

On Unix platforms (expect for iOS, macOS and Solaris) this reduces the
number of system calls from four to two, on iOS, macOS and Solaris this
reduces it to three system calls.

# Windows net initialization

The standard library calls WSAStartup for us, ensuring (with an assert)
that the return value is ok. This means that we can't initialise it
ourselves and need to let the standard library do it for us. To work
around this we create and drop a UdpSocket (from std::net).
2019-08-13 10:02:58 -07:00
Thomas de Zeeuw
2f688de26c Add UdpSocket::peek(_from) methods (#1052) 2019-08-07 15:32:12 -07:00
PerfectLaugh
211223e928 Improve overlapped deallocation strategy and docs (#1042) 2019-08-07 12:09:20 -07:00
Thomas de Zeeuw
a160244f1d Split Event::is_hup into is_hup and is_read_hup and refer to OS selector docs (#1037) 2019-07-21 10:57:47 -07:00
PerfectLaugh
65f19ddcb3 rewrite windows implementation (#1034)
Rewrite the windows implementation using the [wepoll] strategy. This uses the
windows AFD system to access socket readiness events. By doing this, mio no
longer needs to buffer reads and writes internally.

Closes #1024.

[wepoll]: https://github.com/piscisaureus/wepoll
2019-07-19 10:05:03 -07:00
Thomas de Zeeuw
5aeebe2b4e Remove UdpSocket::{recv_bufs, send_bufs}
Still uses IoVec, which we want to remove, and it was unix only.
2019-07-17 12:48:36 +00:00
Thomas de Zeeuw
2a55db6314 Implement vectored I/O for TcpStream (#1016) 2019-07-16 10:07:51 -07:00
Thomas de Zeeuw
79123b738e Remove unused import 2019-07-15 15:46:37 +00:00
Thomas de Zeeuw
512230851d Don't leak file descriptors if registering Waker fails 2019-07-15 15:46:37 +00:00
Thomas de Zeeuw
d312503a84 Replace unsafe transmute with to_ne_bytes in Waker 2019-07-15 15:46:37 +00:00
Thomas de Zeeuw
96ccddf7e2 Reduce unsafe scope in pipe::Waker::new 2019-07-11 17:39:59 +00:00
Thomas de Zeeuw
85dfc79daf Allow module_inception in event::event 2019-07-11 17:39:59 +00:00
Thomas de Zeeuw
058186003b Replace uninitialized with MaybeUninit 2019-07-11 17:39:59 +00:00
Thomas de Zeeuw
dfc987db6e Change sys::Events to Vec<sys::Event> on Unix 2019-07-11 16:57:30 +00:00
Thomas de Zeeuw
cb0ab723c9 Remove cvt (#1026)
And replace the last use of it with the syscall macro.
2019-07-11 08:41:38 -07:00
Thomas de Zeeuw
dc0643c7ae System module cleanup (#1021)
* Remove unused export of IoVec
* Fix type definitions for kevent
* Add syscall macro
* Start NEXT_ID at 1
* Optimize Selector::register to pass a single event to kevent when possible.
* Document when and why some errors returned by kevent are ignored.
* Move calling kevent and checking of errors into there own functions to allow for greater reuse.
* Rename epfd to ep, the type already says it's a file descriptor.
* Use Duration::as_millis, removing the millis function.
* Document unsafe blocks.
* Remove the unneeded info event from deregister as Linux < 2.6.9 is no longer supported.
* Log errors when closing the epoll fd.
2019-07-10 11:25:07 -07:00
Alan Somers
418ff89602 Prefer casting pointers over mem::transmute 2019-07-09 06:24:42 +00:00
Alan Somers
8a5455da6e Prefer pass-by-value over pass-by-reference for public methods
pass-by-value is faster than pass-by-reference for types that are small
and Copy.  This is technically a breaking change since these methods are
public.  However, most crates should compile fine because the only
method argument that's changing is `&self`, which is provided
implicitly.  The only way to get into trouble would be something like
this:

let interests = Interests::new;
Interests::is_readable(&ready)
2019-07-09 06:24:42 +00:00
Alan Somers
5042c6c853 Clippy: fix write_literal warnings
Some diagnostics were using "{}" to format string literals
2019-07-09 06:24:42 +00:00
Alan Somers
b392693351 Clippy: silence an if-same-then-else warning
In this case, it makes the code more clear to duplicate two if clauses
2019-07-09 06:24:42 +00:00
Thomas de Zeeuw
5d61c5e6b5 Log interests and token when registering (#1022) 2019-07-08 13:11:39 -07:00
atouchet
18113ce739 Remove duplicate FreeBSD listings 2019-07-08 09:05:14 +00:00
Thomas de Zeeuw
178f51e8da Rename Evented to event::Source (#1014) 2019-07-05 13:13:10 -07:00
Thomas de Zeeuw
84798948c5 Remove SysEvent (#1018)
Changes sys::Event to be an alias for the platform specific event, e.g.
kevent or epoll_event, what SysEvent used to be.

Next all methods on the old sys::Event become standalone functions in a
new sys::event module, which are used by crate::Event.
2019-07-04 13:32:00 -07:00
Kam Y. Tse
aa84849c61 Switch to use cvt utility function (#1009) 2019-07-02 14:23:49 -07:00
Thomas de Zeeuw
8dd95d5ddb Change addresses in poll example to be local (#1006)
All these example tests failed when offline.
2019-06-26 13:04:42 -07:00
Thomas de Zeeuw
479ae7c5e2 Cleanup of sys::unix (#1005)
* Remove pipe and set_nonblock unix export (not used).

* Move sys::unix::pipe to sys::Waker

Only place where it is used. And since the Waker based is only used on certain platforms directly use pipe2. All the platforms that use pipe based Waker have the pipe2 system call.

* Always use epoll_create1 on epoll platforms

epoll_create1 was introduces in Linux kernel version 2.6.27.

* Remove dlsym module (not used).

* Silence unused warning for set_cloexec (not used).

* Remove sys::unix::io::Io (not used).
2019-06-26 06:52:30 -07:00