[srp-server] retry other ports when failing to prepareSocket (#9981)

Unicast SRP dataset uses a ephemeral UDP port which could be taken by
another process. Currently SRP server creates the socket at the port
after the server is added into netdata. However, at that moment the
port may not be available on the platform so it may fail to create the
socket and start the server.

This commit adds the logic to restart the enabling process with
another port candidate if SRP server fails to create the socket.
This commit is contained in:
Handa Wang
2024-04-03 10:51:50 -07:00
committed by GitHub
parent 0e36799110
commit 843db1e82d
5 changed files with 45 additions and 15 deletions
+3
View File
@@ -197,6 +197,9 @@ class OtbrDocker:
self.pexpect.wait()
self.pexpect.proc.kill()
def reserve_udp_port(self, port):
self.bash(f'socat -u UDP6-LISTEN:{port},bindtodevice=wpan0 - &')
def destroy(self):
logging.info("Destroying %s", self)
self._shutdown_docker()