On Wed, 20 Mar 2024 21:29:24 +0100 Matthias Geiger <werdah...@riseup.net> wrote:
> Package: librust-isahc-dev
> Severity: grave
> Justification: not installable
> X-Debbugs-Cc: werdah...@riseup.net
>

Unfortunately polling 2.x to 3.x had breaking changes. This is my attempt at a

(non-working) patch bumping polling (see attachment). Maybe you can figure out the missing bits; this is too difficult for me.

best,

werdahias
diff --git a/Cargo.toml b/Cargo.toml
index d797d20..62ca8cd 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -43,7 +43,7 @@ futures-io = "0.3.24" # futures-io ecosystem compatibility
 http = "0.2.1" # http ecosystem compatibility, part of API
 log = "0.4" # log ecosystem compatibility
 once_cell = "1" # used for a few singletons
-polling = "2" # async I/O driver
+polling = "3" # async I/O driver
 sluice = "0.5.4" # byte buffers between curl and Isahc
 url = "2.1" # URL parsing
 waker-fn = "1" # async primitive
diff --git a/src/agent/selector.rs b/src/agent/selector.rs
index 813e708..836dd39 100644
--- a/src/agent/selector.rs
+++ b/src/agent/selector.rs
@@ -1,5 +1,5 @@
 use curl::multi::Socket;
-use polling::{Event, Poller};
+use polling::{Event, Poller, Events};
 use std::{
     collections::{HashMap, HashSet},
     io,
@@ -30,7 +30,7 @@ pub(crate) struct Selector {
 
     /// Socket events that have occurred. We re-use this vec every call for
     /// efficiency.
-    events: Vec<Event>,
+    events: Events,
 
     /// Incrementing counter used to deduplicate registration operations.
     tick: usize,
@@ -50,7 +50,7 @@ impl Selector {
             poller: Arc::new(Poller::new()?),
             sockets: HashMap::with_hasher(Default::default()),
             bad_sockets: HashSet::with_hasher(Default::default()),
-            events: Vec::new(),
+            events: Events::new(),
             tick: 0,
         })
     }
@@ -144,7 +144,7 @@ impl Selector {
         // We don't do this immediately after polling because the caller may
         // choose to de-register a socket before the next call. That's why we
         // wait until the last minute.
-        for event in self.events.drain(..) {
+        for event in self.events.iter() {
             let socket = event.key as Socket;
             if let Some(registration) = self.sockets.get_mut(&socket) {
                 // If the socket was already re-registered this tick, then we
@@ -211,21 +211,17 @@ fn poller_add(poller: &Poller, socket: Socket, readable: bool, writable: bool) -
     // operation as a modification is sufficient to handle this.
     //
     // This is especially common with the epoll backend.
-    if let Err(e) = poller.add(socket, Event {
-        key: socket as usize,
-        readable,
-        writable,
-    }) {
+    if let Err(e) = poller.add(socket, 
+        Event::readable(socket.try_into().unwrap()),
+            ) {
         tracing::debug!(
             "failed to add interest for socket {}, retrying as a modify: {}",
             socket,
             e
         );
-        poller.modify(socket, Event {
-            key: socket as usize,
-            readable,
-            writable,
-        })?;
+        poller.modify(socket, 
+        Event::readable(socket.try_into().unwrap()),
+        )?;
     }
 
     Ok(())
@@ -239,21 +235,17 @@ fn poller_modify(
 ) -> io::Result<()> {
     // If this errors, we retry the operation as an add instead. This is done
     // because epoll is weird.
-    if let Err(e) = poller.modify(socket, Event {
-        key: socket as usize,
-        readable,
-        writable,
-    }) {
+    if let Err(e) = poller.modify(socket, 
+        Event::readable(socket.try_into().unwrap()),
+        ) {
         tracing::debug!(
             "failed to modify interest for socket {}, retrying as an add: {}",
             socket,
             e
         );
-        poller.add(socket, Event {
-            key: socket as usize,
-            readable,
-            writable,
-        })?;
+        poller.add(socket,
+        Event::readable(socket.try_into().unwrap()),
+            )?;
     }
 
     Ok(())

Reply via email to