X-Git-Url: https://git.distorted.org.uk/~mdw/tripe/blobdiff_plain/063c9648a6d4650c800a780c79a2171450c5a030..8d4c29d2d46656f85b1ef29ce0020c83fdc8ecf2:/server/peer.c diff --git a/server/peer.c b/server/peer.c index d4155670..377dcc59 100644 --- a/server/peer.c +++ b/server/peer.c @@ -871,13 +871,15 @@ void p_init(struct addrinfo *ailist) sel_initfile(&sel, &udpsock[i].sf, fd, SEL_READ, p_read, 0); sel_addfile(&udpsock[i].sf); T( trace(T_PEER, "peer: created %s socket", aftab[i].name); ) - if (!port) { + if (port) + udpsock[i].port = port; + else { sz = sizeof(a); if (getsockname(fd, &a.sa, &sz)) { die(EXIT_FAILURE, "failed to read local socket address: %s", strerror(errno)); } - lastport = getport(&a); + udpsock[i].port = lastport = getport(&a); } } @@ -885,23 +887,6 @@ void p_init(struct addrinfo *ailist) am_create(&byaddr); } -/* --- @p_port@ --- * - * - * Arguments: @int i@ = address family index to retrieve - * - * Returns: Port number used for socket. - */ - -unsigned p_port(int i) -{ - addr a; - socklen_t sz = sizeof(addr); - - if (getsockname(udpsock[i].sf.fd, &a.sa, &sz)) - die(EXIT_FAILURE, "couldn't read port number: %s", strerror(errno)); - return (getport(&a)); -} - /* --- @p_keepalive@ --- * * * Arguments: @struct timeval *now@ = the current time