Debian Codegraph @

debian/patches/nix-0.27.patch

raw
1 Index: calloop/Cargo.toml
2 ===================================================================
3 --- calloop.orig/Cargo.toml
4 +++ calloop/Cargo.toml
5 @@ -53,7 +53,7 @@ default-features = false
6 version = "0.4"
7
8 [dependencies.nix]
9 -version = "0.26"
10 +version = "0.27"
11 features = [
12 "event",
13 "fs",
14 Index: calloop/src/io.rs
15 ===================================================================
16 --- calloop.orig/src/io.rs
17 +++ calloop/src/io.rs
18 @@ -50,7 +50,7 @@ impl<'l, F: AsRawFd> Async<'l, F> {
19 let rawfd = fd.as_raw_fd();
20 // set non-blocking
21 let old_flags = fcntl(rawfd, FcntlArg::F_GETFL)?;
22 - let old_flags = unsafe { OFlag::from_bits_unchecked(old_flags) };
23 + let old_flags = unsafe { OFlag::from_bits_retain(old_flags) };
24 fcntl(rawfd, FcntlArg::F_SETFL(old_flags | OFlag::O_NONBLOCK))?;
25 // register in the loop
26 let dispatcher = Rc::new(RefCell::new(IoDispatcher {
27 Index: calloop/src/loop_logic.rs
28 ===================================================================
29 --- calloop.orig/src/loop_logic.rs
30 +++ calloop/src/loop_logic.rs
31 @@ -500,6 +500,7 @@ impl LoopSignal {
32 #[cfg(test)]
33 mod tests {
34 use std::time::Duration;
35 + use std::os::fd::IntoRawFd;
36
37 use crate::{
38 generic::Generic, ping::*, Dispatcher, Interest, Mode, Poll, PostAction, Readiness,
39 @@ -747,6 +748,8 @@ mod tests {
40 SockFlag::empty(), // recv with DONTWAIT will suffice for platforms without SockFlag::SOCK_NONBLOCKING such as macOS
41 )
42 .unwrap();
43 + let sock1 = sock1.into_raw_fd();
44 + let sock2 = sock2.into_raw_fd();
45
46 let source = Generic::new(sock1, Interest::READ, Mode::Level);
47 let dispatcher = Dispatcher::new(source, |_, &mut fd, dispatched| {
48 Index: calloop/src/sources/ping/eventfd.rs
49 ===================================================================
50 --- calloop.orig/src/sources/ping/eventfd.rs
51 +++ calloop/src/sources/ping/eventfd.rs
52 @@ -19,6 +19,7 @@
53 //! only works if a close event never fires more than once.
54
55 use std::{os::unix::io::RawFd, sync::Arc};
56 +use std::os::fd::IntoRawFd;
57
58 use nix::sys::eventfd::{eventfd, EfdFlags};
59 use nix::unistd::{read, write};
60 @@ -37,6 +38,7 @@ const INCREMENT_CLOSE: u64 = 0x1;
61 #[inline]
62 pub fn make_ping() -> std::io::Result<(Ping, PingSource)> {
63 let read = eventfd(0, EfdFlags::EFD_CLOEXEC | EfdFlags::EFD_NONBLOCK)?;
64 + let read = read.into_raw_fd();
65
66 // We only have one fd for the eventfd. If the sending end closes it when
67 // all copies are dropped, the receiving end will be closed as well. We need
68 Index: calloop/src/sources/signals.rs
69 ===================================================================
70 --- calloop.orig/src/sources/signals.rs
71 +++ calloop/src/sources/signals.rs
72 @@ -46,6 +46,19 @@ pub struct Signals {
73 mask: SigSet,
74 }
75
76 +trait MySetMask {
77 + fn my_set_mask(&mut self, mask: &SigSet) -> nix::Result<()>;
78 +}
79 +
80 +use std::os::fd::AsFd;
81 +//workaround for https://github.com/nix-rust/nix/issues/2116
82 +impl MySetMask for SignalFd {
83 + fn my_set_mask(&mut self, mask: &SigSet) -> nix::Result<()> {
84 + nix::sys::signalfd::signalfd(Some(self.as_fd()), &mask, SfdFlags::empty())
85 + .map(std::mem::forget)
86 + }
87 +}
88 +
89 impl Signals {
90 /// Create a new signal event source listening on the specified list of signals
91 pub fn new(signals: &[Signal]) -> crate::Result<Signals> {
92 @@ -74,7 +87,7 @@ impl Signals {
93 self.mask.add(s);
94 }
95 self.mask.thread_block()?;
96 - self.sfd.file.set_mask(&self.mask)?;
97 + self.sfd.file.my_set_mask(&self.mask)?;
98 Ok(())
99 }
100
101 @@ -89,7 +102,7 @@ impl Signals {
102 removed.add(s);
103 }
104 removed.thread_unblock()?;
105 - self.sfd.file.set_mask(&self.mask)?;
106 + self.sfd.file.my_set_mask(&self.mask)?;
107 Ok(())
108 }
109
110 @@ -105,7 +118,7 @@ impl Signals {
111
112 self.mask.thread_unblock()?;
113 new_mask.thread_block()?;
114 - self.sfd.file.set_mask(&new_mask)?;
115 + self.sfd.file.my_set_mask(&new_mask)?;
116 self.mask = new_mask;
117
118 Ok(())
119 Index: calloop/src/sys/epoll.rs
120 ===================================================================
121 --- calloop.orig/src/sys/epoll.rs
122 +++ calloop/src/sys/epoll.rs
123 @@ -1,4 +1,5 @@
124 use std::os::unix::io::{AsRawFd, RawFd};
125 +use std::os::fd::AsFd;
126
127 use super::{Interest, Mode, PollEvent, Readiness, Token};
128
129 @@ -58,7 +59,7 @@ impl Epoll {
130 epoll_ctl(
131 epoll_fd,
132 EpollOp::EpollCtlAdd,
133 - timer.as_raw_fd(),
134 + timer.as_fd().as_raw_fd(),
135 &mut timer_event,
136 )?;
137 timer_fd = Some(timer);