Commit b5e4118a authored by Antoine Millet's avatar Antoine Millet
Browse files

Send ready message only when tunnel is started

parent 101b3eb5
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ class TunnelProtocol(Protocol):
            self._socket = None

        self._is_shutdown = threading.Event()
        self._is_started = autostart
        self._is_started = False
        self._from_tun_to_endpoint_buf = ''
        self._asked = 0 # Data asked to the peer
        self._ok_to_send = 0 # Data I can send to the peer
@@ -46,8 +46,8 @@ class TunnelProtocol(Protocol):
                     callback=self._handle_from_tunnel)
        self._endpoint_writer = self.create_watcher(pyev.Io, **props)

        self._connection.rpc.send_special('protoctl', label=self._label,
                                          type='ready')
        if autostart:
            self.start()

    def _handle_from_endpoint(self, watcher, revents):
        """ Handle data coming from the endpoint socket and push it through the
@@ -130,6 +130,7 @@ class TunnelProtocol(Protocol):
        """ Start the reader on the endpoint.
        """
        if not self._is_shutdown.is_set():
            self._connection.rpc.send_special('protoctl', label=self._label, type='ready')
            self._is_started = True
            self._endpoint_reader.start()