X-Git-Url: https://git.distorted.org.uk/~mdw/tripe/blobdiff_plain/917c5c17c0321c7ebd31737261a62de768da4a75..bf302d900e1658e664e4e7c05bb2748c4677dfc6:/server/peer.c diff --git a/server/peer.c b/server/peer.c index 5855f2e1..f723cccb 100644 --- a/server/peer.c +++ b/server/peer.c @@ -894,6 +894,32 @@ void p_bind(struct addrinfo *ailist) } +/* --- @p_unbind@ --- * + * + * Arguments: --- + * + * Returns: --- + * + * Use: Unbinds the UDP sockets. There must not be any active peers, + * and none can be created until the sockets are rebound. + */ + +void p_unbind(void) +{ + int i; + +#ifndef NDEBUG + { peer_iter it; p_mkiter(&it); assert(!p_next(&it)); } +#endif + + for (i = 0; i < NADDRFAM; i++) { + if (udpsock[i].sf.fd == -1) continue; + sel_rmfile(&udpsock[i].sf); + close(udpsock[i].sf.fd); + udpsock[i].sf.fd = -1; + } +} + /* --- @p_init@ --- * * * Arguments: ---