From: Claudio-Daniel Freire Date: Mon, 18 Apr 2011 16:16:11 +0000 (+0200) Subject: Fix tun_connect not to use 100% CPU (by only waiting for write-ready sockets that... X-Git-Tag: nepi_v2~152 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=cd51a49eaf8fe7f83f6bc99d2ba6acb51267e5b2;p=nepi.git Fix tun_connect not to use 100% CPU (by only waiting for write-ready sockets that really need to write) --- diff --git a/scripts/tun_connect.py b/scripts/tun_connect.py index ba74a6ad..c416557e 100644 --- a/scripts/tun_connect.py +++ b/scripts/tun_connect.py @@ -310,7 +310,12 @@ def tun_fwd(tun, remote): fwbuf = "" bkbuf = "" while not abortme: - rdrdy, wrdy, errs = select.select((tun,remote),(tun,remote),(tun,remote),1) + wset = [] + if packetReady(bkbuf): + wset.append(tun) + if packetReady(fwbuf): + wset.append(remote) + rdrdy, wrdy, errs = select.select((tun,remote),wset,(tun,remote),1) # check for errors if errs: