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

+3
View File
@@ -34,11 +34,14 @@ def gsmtap_msg_type(sub_type):
class GsmtapListener:
def __init__(self, bind_port=4729):
self._bind_port = bind_port
self._receiver = GsmtapReceiver(bind_port=bind_port)
self._running = False
self._dropped = 0
def start(self):
if getattr(self._receiver, '_closed', False):
self._receiver = GsmtapReceiver(bind_port=self._bind_port)
self._running = True
self._dropped = 0