From: Jeffrey Hutzelman Date: Thu, 11 Jan 2001 05:59:34 +0000 (+0000) Subject: allow-rx-newservice-with-zero-port-after-rx-init-zero-20010111 X-Git-Tag: BP-openafs-devel-autoconf~124 X-Git-Url: https://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=c12b66c1bec412d928bbcb62c7eb3b3caad3511c allow-rx-newservice-with-zero-port-after-rx-init-zero-20010111 The intent is to allow services to be set up on random rather than fixed ports --- diff --git a/src/rx/rx.c b/src/rx/rx.c index ace254d..eca7a5b 100644 --- a/src/rx/rx.c +++ b/src/rx/rx.c @@ -446,9 +446,22 @@ int rx_Init(u_int port) #else osi_GetTime(&tv); #endif - /* *Slightly* random start time for the cid. This is just to help - * out with the hashing function at the peer */ - rx_port = port; + if (port) { + rx_port = port; + } else { +#if defined(KERNEL) && !defined(UKERNEL) + /* Really, this should never happen in a real kernel */ + rx_port = 0; +#else + struct sockaddr_in addr; + int addrlen = sizeof(addr); + if (getsockname(rx_socket, (struct sockaddr *) &addr, &addrlen)) { + rx_Finalize(); + return -1; + } + rx_port = addr.sin_port; +#endif + } rx_stats.minRtt.sec = 9999999; #ifdef KERNEL rx_SetEpoch (tv.tv_sec | 0x80000000); @@ -459,6 +472,8 @@ int rx_Init(u_int port) MUTEX_ENTER(&rx_stats_mutex); rxi_dataQuota += rx_extraQuota; /* + extra pkts caller asked to rsrv */ MUTEX_EXIT(&rx_stats_mutex); + /* *Slightly* random start time for the cid. This is just to help + * out with the hashing function at the peer */ rx_nextCid = ((tv.tv_sec ^ tv.tv_usec) << RX_CIDSHIFT); rx_connHashTable = (struct rx_connection **) htable; rx_peerHashTable = (struct rx_peer **) ptable;