tests: bmpserver, detect session close immediately

bmpserver infinitely loops after the clients has closed the TCP session.
In this situation, recv() returns empty data.

Detect session close immediately.

Fixes: 875511c466 ("topotests: add basic bmp collector")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
This commit is contained in:
Louis Scalbert 2024-10-23 12:25:42 +02:00
parent 6bb0c91d10
commit ad6c107f91

View File

@ -34,6 +34,9 @@ def main():
try: try:
while True: while True:
data = connection.recv(BGP_MAX_SIZE) data = connection.recv(BGP_MAX_SIZE)
if not data:
# connection closed
break
while len(data) > BMPMsg.MIN_LEN: while len(data) > BMPMsg.MIN_LEN:
data = BMPMsg.dissect(data, log_file=LOG_FILE) data = BMPMsg.dissect(data, log_file=LOG_FILE)
except Exception as e: except Exception as e: