Fix GSMTAP capture restart: recreate UDP socket on start after stop

GsmtapListener.stop() closed the UDP socket permanently, but start()
only set _running=True without recreating it. Second capture session
would silently spin on the dead socket (OSError → None → continue).

- Add _closed flag to GsmtapReceiver, set in close()
- Store bind_port in GsmtapListener for socket recreation
- start() recreates GsmtapReceiver only if previous one was closed
- Uses getattr for backward compat with test fakes
This commit is contained in:
catarrh committed 2026-09-06 21:09:04 +03:00
1 parent 78c255464e
commit 7d8dca1ffd
2 files changed
+5

No files matched your search

+2
View File
@@ -79,6 +79,7 @@ class GsmtapReceiver:
self._sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
self._sock.bind((bind_ip, bind_port))
self._sock.settimeout(1.0)
self._closed = False
def read_packet(self):
"""Block until a GSMTAP-SIM packet arrives.
@@ -109,3 +110,4 @@ class GsmtapReceiver:
def close(self):
self._sock.close()
self._closed = True