]> git.ipfire.org Git - thirdparty/strongswan.git/commit
vici: Generalize timeout support in Python bindings
authorJean-Tiare Le Bigot <jt@yadutaf.fr>
Thu, 2 Mar 2023 22:20:13 +0000 (23:20 +0100)
committerTobias Brunner <tobias@strongswan.org>
Fri, 10 Mar 2023 08:10:44 +0000 (09:10 +0100)
commitbb6174a4d1114648a5c04d05fc5a66262bfe3248
tree23f6e84910a9899762a099d86bf586da5a401889
parent89936186a83e761755f900afe626017bdf75bef6
vici: Generalize timeout support in Python bindings

Since 3dd5dc50119d ("Merge branch 'vici-python-timeout'"), any timeout
set directly on the socket is reset by `vici.Transport.receive()` unless
called by `vici.Session.listen()`. This prevents configuring a default
timeout directly on the socket.

However, setting a timeout directly on the socket also had drawbacks
since it can cause `vici.Transport.receive()` to raise a timeout error
while a subset of the data have been received, with no way to recover.

This commit merges both approaches by considering the timeout configured
on the socket by default (when no timeout is explicitly set) and
keeping the switch to blocking receive once the first byte has been
received. When the full expected data have been received, the timeout
configured on the socket is restored.

Co-authored-by: Tobias Brunner <tobias@strongswan.org>
Signed-off-by: Jean-Tiare Le Bigot <jt@yadutaf.fr>
Closes strongswan/strongswan#1562
src/libcharon/plugins/vici/python/vici/protocol.py
src/libcharon/plugins/vici/python/vici/session.py