#ifndef AFS_NT40_ENV
# include <sys/time.h>
#endif
+# include "rx_internal.h"
# include "rx.h"
# include "rx_globals.h"
len1 = 32766;
len2 = rx_UdpBufSize;
- greedy =
- (setsockopt
- (socketFd, SOL_SOCKET, SO_RCVBUF, (char *)&len2,
- sizeof(len2)) >= 0);
- if (!greedy) {
- len2 = 32766; /* fall back to old size... uh-oh! */
- }
- greedy =
+ /* find the size closest to rx_UdpBufSize that will be accepted */
+ while (!greedy && len2 > len1) {
+ greedy =
+ (setsockopt
+ (socketFd, SOL_SOCKET, SO_RCVBUF, (char *)&len2,
+ sizeof(len2)) >= 0);
+ if (!greedy)
+ len2 /= 2;
+ }
+
+ /* but do not let it get smaller than 32K */
+ if (len2 < len1)
+ len2 = len1;
+
+ if (len1 < len2)
+ len1 = len2;
+
+
+ greedy =
(setsockopt
(socketFd, SOL_SOCKET, SO_SNDBUF, (char *)&len1,
sizeof(len1)) >= 0)
}
void
-osi_Panic(msg, a1, a2, a3)
- char *msg;
+osi_Panic(char *msg, ...)
{
+ va_list ap;
+ va_start(ap, msg);
(osi_Msg "Fatal Rx error: ");
- (osi_Msg msg, a1, a2, a3);
+ (osi_VMsg msg, ap);
+ va_end(ap);
fflush(stderr);
fflush(stdout);
afs_abort();
** maxSize - max number of interfaces to return.
*/
int
-rx_getAllAddr(afs_int32 * buffer, int maxSize)
+rx_getAllAddr(afs_uint32 * buffer, int maxSize)
{
int count = 0, offset = 0;
/* The IP address list can change so we must query for it */
rx_GetIFInfo();
-#ifndef AFS_NT40_ENV
+#ifdef AFS_DJGPP_ENV
/* we don't want to use the loopback adapter which is first */
/* this is a bad bad hack.
* and doesn't hold true on Windows.
*/
if ( rxi_numNetAddrs > 1 )
offset = 1;
-#endif /* AFS_NT40_ENV */
+#endif /* AFS_DJGPP_ENV */
for (count = 0; offset < rxi_numNetAddrs && maxSize > 0;
count++, offset++, maxSize--)
return count;
}
+
+/* this function returns the total number of interface addresses
+ * the buffer has to be passed in by the caller. It also returns
+ * the matching interface mask and mtu. All values are returned
+ * in network byte order.
+ */
+int
+rx_getAllAddrMaskMtu(afs_uint32 addrBuffer[], afs_uint32 maskBuffer[],
+ afs_uint32 mtuBuffer[], int maxSize)
+{
+ int count = 0, offset = 0;
+
+ /* The IP address list can change so we must query for it */
+ rx_GetIFInfo();
+
+#ifdef AFS_DJGPP_ENV
+ /* we don't want to use the loopback adapter which is first */
+ /* this is a bad bad hack.
+ * and doesn't hold true on Windows.
+ */
+ if ( rxi_numNetAddrs > 1 )
+ offset = 1;
+#endif /* AFS_DJGPP_ENV */
+
+ for (count = 0;
+ offset < rxi_numNetAddrs && maxSize > 0;
+ count++, offset++, maxSize--) {
+ addrBuffer[count] = htonl(rxi_NetAddrs[offset]);
+ maskBuffer[count] = htonl(myNetMasks[offset]);
+ mtuBuffer[count] = htonl(myNetMTUs[offset]);
+ }
+ return count;
+}
#endif
#ifdef AFS_NT40_ENV
+extern int rxinit_status;
+void
+rxi_InitMorePackets(void) {
+ int npackets, ncbufs;
+
+ ncbufs = (rx_maxJumboRecvSize - RX_FIRSTBUFFERSIZE);
+ if (ncbufs > 0) {
+ ncbufs = ncbufs / RX_CBUFFERSIZE;
+ npackets = rx_initSendWindow - 1;
+ rxi_MorePackets(npackets * (ncbufs + 1));
+ }
+}
void
rx_GetIFInfo(void)
{
u_int maxsize;
u_int rxsize;
- int npackets, ncbufs;
afs_uint32 i;
LOCK_IF_INIT;
+ if (Inited) {
+ if (Inited < 2 && rxinit_status == 0) {
+ /* We couldn't initialize more packets earlier.
+ * Do it now. */
+ rxi_InitMorePackets();
+ Inited = 2;
+ }
+ UNLOCK_IF_INIT;
+ return;
+ }
Inited = 1;
UNLOCK_IF_INIT;
}
UNLOCK_IF;
- ncbufs = (rx_maxJumboRecvSize - RX_FIRSTBUFFERSIZE);
- if (ncbufs > 0) {
- ncbufs = ncbufs / RX_CBUFFERSIZE;
- npackets = rx_initSendWindow - 1;
- rxi_MorePackets(npackets * (ncbufs + 1));
- }
+
+ /*
+ * If rxinit_status is still set, rx_InitHost() has yet to be called
+ * and we therefore do not have any mutex locks initialized. As a
+ * result we cannot call rxi_MorePackets() without crashing.
+ */
+ if (rxinit_status)
+ return;
+
+ rxi_InitMorePackets();
}
#endif
pp->natMTU = MIN((int)pp->ifMTU, OLD_MAX_PACKET_SIZE);
pp->maxDgramPackets =
MIN(rxi_nDgramPackets,
- rxi_AdjustDgramPackets(RX_MAX_FRAGS, pp->ifMTU));
+ rxi_AdjustDgramPackets(rxi_nSendFrags, pp->ifMTU));
pp->ifDgramPackets =
MIN(rxi_nDgramPackets,
- rxi_AdjustDgramPackets(RX_MAX_FRAGS, pp->ifMTU));
+ rxi_AdjustDgramPackets(rxi_nSendFrags, pp->ifMTU));
pp->maxDgramPackets = 1;
/* Initialize slow start parameters */
pp->MTU = MIN(pp->natMTU, pp->maxMTU);