Skip to content

Commit 9ae0471

Browse files
committed
isotpsoft: optimize for slow (slcan) interfaces: don't call select when the internal state will do
1 parent 0fc6f1d commit 9ae0471

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

scapy/contrib/isotp/isotp_soft_socket.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,14 @@ def can_recv(self):
611611
log_isotp.warning("Error in can_recv: %s",
612612
traceback.format_exc())
613613
if not self.closed and not self.can_socket.closed:
614-
if self.can_socket.select([self.can_socket], 0):
614+
# Determine poll_time from ISOTP state only.
615+
# Avoid calling select() here — on slow serial interfaces
616+
# (slcan), each select() triggers a mux() call that reads
617+
# N frames at ~2.5ms each, wasting time that could be spent
618+
# processing frames already in the rx_queue.
619+
if self.rx_state == ISOTP_WAIT_DATA or \
620+
self.tx_state == ISOTP_WAIT_FC or \
621+
self.tx_state == ISOTP_WAIT_FIRST_FC:
615622
poll_time = 0.0
616623
else:
617624
poll_time = self.rx_tx_poll_rate

0 commit comments

Comments
 (0)