xpra icon
Bug tracker and wiki

Ticket #2676: udp-dont-wait-too-long.patch

File udp-dont-wait-too-long.patch, 2.6 KB (added by Antoine Martin, 8 months ago)

try not to wait for too long if a sequence is just not coming through

  • xpra/net/udp_protocol.py

     
    128128        super().__init__(*args)
    129129        self.mtu = 0
    130130        self.last_sequence = -1     #the most recent packet sequence we processed in full
     131        self.last_sequence_time = 0
    131132        self.highest_sequence = -1
    132133        self.jitter = 20            #20ms
    133134        self.uuid = kwargs.get("uuid", 0)
     
    179180        if self._closed:
    180181            return False
    181182        missing = self._get_missing()
     183        log.info("send_control() missing=%s", missing)
    182184        packet = ("udp-control", self.mtu, self.asynchronous_receive_enabled,
    183185                  self.last_sequence, self.highest_sequence, missing, tuple(self.cancel))
    184186        log("send_control() packet(%s)=%s", self.pending_packets, ellipsizer(packet))
     
    368370                if synchronous:
    369371                    #we have to wait for the missing chunks / packets
    370372                    log("process_udp_data: queuing %i as we're still waiting for %i", seqno, self.last_sequence+1)
     373                    if self.last_sequence_time:
     374                        elapsed = self.last_sequence_time-monotonic_time()
     375                        if elapsed>10:
     376                            log.error("Error: UDP protocol error")
     377                            log.error(" sequence %i is taking far too long", self.last_sequence+1)
     378                            self.close()
    371379                    return
    372380            missing = tuple(i for i, x in enumerate(ip.chunks) if x is None)
    373381            if missing:
     
    394402            seqno, len(data), chunk, synchronous!=0)
    395403        if seqno==self.last_sequence+1:
    396404            self.last_sequence = seqno
     405            self.last_sequence_time = monotonic_time()
    397406        else:
    398407            assert not synchronous
    399408            self.can_skip.add(seqno)
     
    419428                    pass
    420429                self.can_skip.remove(seqno)
    421430                self.last_sequence = seqno
     431                self.last_sequence_time = monotonic_time()
    422432                continue
    423433            ip = self.pending_packets.get(seqno)
    424434            if not ip or not ip.chunks:
     
    432442            data = b"".join(ip.chunks)
    433443            log("process_pending: adding packet sequence %5i to read queue", seqno)
    434444            self.last_sequence = seqno
     445            self.last_sequence_time = monotonic_time()
    435446            self._read_queue_put(data)
    436447
    437448    def raw_write(self, packet_type, items, start_cb=None, end_cb=None, fail_cb=None, synchronous=True, _more=False):