mirror of https://github.com/secdev/scapy.git
Restart select when we see a EINTR
This fixes erratic behavior when scapy is run inside of a separate thread or in another process. The patch is taken from https://bitbucket.org/secdev/scapy/issues/473/scapy-sendrecv-selects-eintr-problem-in
This commit is contained in:
parent
40045ea3e9
commit
78aff2eb73
|
@ -7,6 +7,7 @@
|
||||||
Functions to send and receive packets.
|
Functions to send and receive packets.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import errno
|
||||||
import cPickle,os,sys,time,subprocess
|
import cPickle,os,sys,time,subprocess
|
||||||
import itertools
|
import itertools
|
||||||
from select import select
|
from select import select
|
||||||
|
@ -127,7 +128,12 @@ def sndrcv(pks, pkt, timeout = None, inter = 0, verbose=None, chainCC=0, retry=0
|
||||||
if len(inp) == 0 or pks in inp:
|
if len(inp) == 0 or pks in inp:
|
||||||
r = pks.nonblock_recv()
|
r = pks.nonblock_recv()
|
||||||
else:
|
else:
|
||||||
inp, out, err = select(inmask,[],[], remaintime)
|
inp = []
|
||||||
|
try:
|
||||||
|
inp, out, err = select(inmask,[],[], remaintime)
|
||||||
|
except IOError, exc:
|
||||||
|
if exc.errno != errno.EINTR:
|
||||||
|
raise
|
||||||
if len(inp) == 0:
|
if len(inp) == 0:
|
||||||
break
|
break
|
||||||
if pks in inp:
|
if pks in inp:
|
||||||
|
|
Loading…
Reference in New Issue