Commit 0e99adc5 authored by Alex Tomlins's avatar Alex Tomlins Committed by Brian May

Fix potential deadlock condition in nft_get_handle

This was susceptible to the same deadlock issue that ipt_chain_exists
had and was fixed in d43db80d where if the command returned a significant
amount of output, it wouldn't all be read in, resulting in the
subprocess hanging waiting for the output to be read.
parent 04849df7
......@@ -74,13 +74,13 @@ def nft_get_handle(expression, chain):
'PATH': os.environ['PATH'],
'LC_ALL': "C",
}
p = ssubprocess.Popen(argv, stdout=ssubprocess.PIPE, env=env)
for line in p.stdout:
if (b'jump %s' % chain.encode('utf-8')) in line:
return re.sub('.*# ', '', line.decode('utf-8'))
rv = p.wait()
if rv:
raise Fatal('%r returned %d' % (argv, rv))
try:
output = ssubprocess.check_output(argv, env=env)
for line in output.decode('utf-8').split('\n'):
if ('jump %s' % chain) in line:
return re.sub('.*# ', '', line)
except ssubprocess.CalledProcessError as e:
raise Fatal('%r returned %d' % (argv, e.returncode))
_no_ttl_module = False
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment