Commit 8a46afe3 authored by Elena's avatar Elena 🤷‍♀️ Committed by Pier Angelo Vendrame
Browse files

fixup! TB 44806: Implement the tor integration in Rust.

TB 44930: Implement the commands on the Rust control port

Reorder some methods.
parent 491ab443
Loading
Loading
Loading
Loading
+18 −18
Original line number Diff line number Diff line
@@ -79,19 +79,6 @@ impl ControlPortInner {
        }
    }

    fn close(&self) -> Result<(), ControlSocketError> {
        if self.closed.replace(true) {
            return Ok(());
        }
        self.reply_dispatcher.fail_all(ReplyError::ConnectionClosed);
        self.reply_dispatcher.set_async_handler(None);
        self.socket.close()
    }

    fn set_async_handler(&self, cb: Option<Box<dyn Fn(Reply)>>) {
        self.reply_dispatcher.set_async_handler(cb);
    }

    fn send_command(
        self: &Rc<Self>,
        command: Bytes,
@@ -136,6 +123,19 @@ impl ControlPortInner {
            }),
        );
    }

    fn set_async_handler(&self, cb: Option<Box<dyn Fn(Reply)>>) {
        self.reply_dispatcher.set_async_handler(cb);
    }

    fn close(&self) -> Result<(), ControlSocketError> {
        if self.closed.replace(true) {
            return Ok(());
        }
        self.reply_dispatcher.fail_all(ReplyError::ConnectionClosed);
        self.reply_dispatcher.set_async_handler(None);
        self.socket.close()
    }
}

impl Drop for ControlPortInner {
@@ -157,11 +157,6 @@ impl ControlPort {
        Ok(Self(ControlPortInner::new(Rc::from(socket))?))
    }

    #[inline]
    pub fn close(&self) -> Result<(), ControlSocketError> {
        self.0.close()
    }

    // TODO: Keep only the methods speicifc to commands and remove this one
    // (tor-browser#44930).
    #[inline]
@@ -177,4 +172,9 @@ impl ControlPort {
    pub fn set_async_handler(&self, cb: Option<Box<dyn Fn(Reply)>>) {
        self.0.set_async_handler(cb);
    }

    #[inline]
    pub fn close(&self) -> Result<(), ControlSocketError> {
        self.0.close()
    }
}