rx: Remove the ADAPT_WINDOW code
[openafs.git] / src / rx / rx_kcommon.c
index f50abeb..664497e 100644 (file)
@@ -12,7 +12,7 @@
  */
 
 #include <afsconfig.h>
-#include "afs/param.h"
+#include <afs/param.h>
 
 
 #include "rx/rx_kcommon.h"
@@ -114,7 +114,7 @@ rxi_GetHostUDPSocket(u_int host, u_short port)
     sockp = (osi_socket *)rxk_NewSocketHost(host, port);
     if (sockp == (osi_socket *)0)
        return OSI_NULLSOCKET;
-       rxk_AddPort(port, (char *)sockp);
+    rxk_AddPort(port, (char *)sockp);
     return (osi_socket) sockp;
 }
 
@@ -347,8 +347,8 @@ MyArrivalProc(struct rx_packet *ahandle,
 void
 rxi_StartListener(void)
 {
+#if !defined(RXK_LISTENER_ENV) && !defined(RXK_UPCALL_ENV)
     /* if kernel, give name of appropriate procedures */
-#ifndef RXK_LISTENER_ENV
     rxk_GetPacketProc = MyPacketProc;
     rxk_PacketArrivalProc = MyArrivalProc;
     rxk_init();
@@ -370,12 +370,10 @@ rxi_InitPeerParams(struct rx_peer *pp)
 
     i = rxi_Findcbi(pp->host);
     if (i == -1) {
-       pp->timeout.sec = 3;
-       /* pp->timeout.usec = 0; */
+       rx_rto_setPeerTimeoutSecs(pp, 3);
        pp->ifMTU = MIN(RX_REMOTE_PACKET_SIZE, rx_MyMaxSendSize);
     } else {
-       pp->timeout.sec = 2;
-       /* pp->timeout.usec = 0; */
+       rx_rto_setPeerTimeoutSecs(pp, 2);
        pp->ifMTU = MIN(RX_MAX_PACKET_SIZE, rx_MyMaxSendSize);
        mtu = ntohl(afs_cb_interface.mtu[i]);
        /* Diminish the packet size to one based on the MTU given by
@@ -396,13 +394,12 @@ rxi_InitPeerParams(struct rx_peer *pp)
 
     ifn = rxi_FindIfnet(pp->host, NULL);
     if (ifn) {
-       pp->timeout.sec = 2;
-       /* pp->timeout.usec = 0; */
+       rx_rto_setPeerTimeoutSecs(pp, 2);
        pp->ifMTU = MIN(RX_MAX_PACKET_SIZE, rx_MyMaxSendSize);
 #   ifdef IFF_POINTOPOINT
        if (rx_ifnet_flags(ifn) & IFF_POINTOPOINT) {
            /* wish we knew the bit rate and the chunk size, sigh. */
-           pp->timeout.sec = 4;
+           rx_rto_setPeerTimeoutSecs(pp, 4);
            pp->ifMTU = RX_PP_PACKET_SIZE;
        }
 #   endif /* IFF_POINTOPOINT */
@@ -414,8 +411,7 @@ rxi_InitPeerParams(struct rx_peer *pp)
                pp->ifMTU = rxmtu;
        }
     } else {                   /* couldn't find the interface, so assume the worst */
-       pp->timeout.sec = 3;
-       /* pp->timeout.usec = 0; */
+       rx_rto_setPeerTimeoutSecs(pp, 3);
        pp->ifMTU = MIN(RX_REMOTE_PACKET_SIZE, rx_MyMaxSendSize);
     }
 #  endif /* else AFS_USERSPACE_IP_ADDR */
@@ -425,12 +421,10 @@ rxi_InitPeerParams(struct rx_peer *pp)
     mtu = rxi_FindIfMTU(pp->host);
 
     if (mtu <= 0) {
-       pp->timeout.sec = 3;
-       /* pp->timeout.usec = 0; */
+       rx_rto_setPeerTimeoutSecs(pp, 3);
        pp->ifMTU = MIN(RX_REMOTE_PACKET_SIZE, rx_MyMaxSendSize);
     } else {
-       pp->timeout.sec = 2;
-       /* pp->timeout.usec = 0; */
+       rx_rto_setPeerTimeoutSecs(pp, 2);
        pp->ifMTU = MIN(RX_MAX_PACKET_SIZE, rx_MyMaxSendSize);
 
        /* Diminish the packet size to one based on the MTU given by
@@ -443,8 +437,7 @@ rxi_InitPeerParams(struct rx_peer *pp)
     }
 # endif /* AFS_SUN5_ENV */
 #else /* ADAPT_MTU */
-    pp->rateFlag = 2;          /* start timing after two full packets */
-    pp->timeout.sec = 2;
+    rx_rto_setPeerTimeoutSecs(pp, 2);
     pp->ifMTU = OLD_MAX_PACKET_SIZE;
 #endif /* else ADAPT_MTU */
     pp->ifMTU = rxi_AdjustIfMTU(pp->ifMTU);
@@ -667,7 +660,11 @@ rxi_GetIFInfo(void)
     }
 #else
 #if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
+#if defined(AFS_FBSD80_ENV)
+    TAILQ_FOREACH(ifn, &V_ifnet, if_link) {
+#else
     TAILQ_FOREACH(ifn, &ifnet, if_link) {
+#endif
        if (i >= ADDRSPERSITE)
            break;
 #elif defined(AFS_OBSD_ENV) || defined(AFS_NBSD_ENV)
@@ -861,9 +858,13 @@ rxk_NewSocketHost(afs_uint32 ahost, short aport)
     code = socreate(AF_INET, &newSocket, SOCK_DGRAM, IPPROTO_UDP,
                    afs_osi_credp, curthread);
 #elif defined(AFS_DARWIN80_ENV)
+#ifdef RXK_LISTENER_ENV
     code = sock_socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP, NULL, NULL, &newSocket);
+#else
+    code = sock_socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP, rx_upcall, NULL, &newSocket);
+#endif
 #elif defined(AFS_NBSD50_ENV)
-       code = socreate(AF_INET, &newSocket, SOCK_DGRAM, 0, osi_curproc(), NULL);
+    code = socreate(AF_INET, &newSocket, SOCK_DGRAM, 0, osi_curproc(), NULL);
 #elif defined(AFS_NBSD40_ENV)
     code = socreate(AF_INET, &newSocket, SOCK_DGRAM, 0, osi_curproc());
 #else
@@ -921,12 +922,18 @@ rxk_NewSocketHost(afs_uint32 ahost, short aport)
        }
     }
 #else
+#if defined(AFS_NBSD_ENV)
+    solock(newSocket);
+#endif
     code = soreserve(newSocket, 50000, 50000);
     if (code) {
        code = soreserve(newSocket, 32766, 32766);
        if (code)
            osi_Panic("osi_NewSocket: last attempt to reserve 32K failed!\n");
     }
+#if defined(AFS_NBSD_ENV)
+    sounlock(newSocket);
+#endif
 #endif
 #if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
 #if defined(AFS_FBSD_ENV)
@@ -1021,8 +1028,8 @@ rxk_FreeSocket(struct socket *asocket)
 }
 #endif /* !SUN5 && !LINUX20 */
 
-#if defined(RXK_LISTENER_ENV) || defined(AFS_SUN5_ENV)
-#ifdef AFS_DARWIN80_ENV
+#if defined(RXK_LISTENER_ENV) || defined(AFS_SUN5_ENV) || defined(RXK_UPCALL_ENV)
+#ifdef RXK_TIMEDSLEEP_ENV
 /* Shutting down should wake us up, as should an earlier event. */
 void
 rxi_ReScheduleEvents(void)
@@ -1059,7 +1066,7 @@ afs_rxevent_daemon(void)
        afs_Trace1(afs_iclSetp, CM_TRACE_TIMESTAMP, ICL_TYPE_STRING,
                   "before afs_osi_Wait()");
 #endif
-#ifdef AFS_DARWIN80_ENV
+#ifdef RXK_TIMEDSLEEP_ENV
        afs_osi_TimedSleep(&afs_termState, MAX(500, ((temp.sec * 1000) +
                                                     (temp.usec / 1000))), 0);
 #else
@@ -1072,13 +1079,11 @@ afs_rxevent_daemon(void)
        if (afs_termState == AFSOP_STOP_RXEVENT) {
 #ifdef RXK_LISTENER_ENV
            afs_termState = AFSOP_STOP_RXK_LISTENER;
-#else
-#ifdef AFS_SUN510_ENV
+#elif defined(AFS_SUN510_ENV) || defined(RXK_UPCALL_ENV)
            afs_termState = AFSOP_STOP_NETIF;
 #else
            afs_termState = AFSOP_STOP_COMPLETE;
 #endif
-#endif
            osi_rxWakeup(&afs_termState);
            return;
        }
@@ -1197,28 +1202,9 @@ int rxk_ListenerPid;             /* Used to signal process to wakeup at shutdown */
 struct task_struct *rxk_ListenerTask;
 #endif
 
-#ifdef AFS_SUN5_ENV
-/*
- * Run the listener as a kernel thread.
- */
 void
 rxk_Listener(void)
 {
-    extern id_t syscid;
-    void rxk_ListenerProc(void);
-    if (thread_create
-       (NULL, DEFAULTSTKSZ, rxk_ListenerProc, 0, 0, &p0, TS_RUN,
-        minclsyspri) == NULL)
-       osi_Panic("rxk_Listener: failed to start listener thread!\n");
-}
-
-void
-rxk_ListenerProc(void)
-#else /* AFS_SUN5_ENV */
-void
-rxk_Listener(void)
-#endif                         /* AFS_SUN5_ENV */
-{
     struct rx_packet *rxp = NULL;
     int code;
     int host, port;
@@ -1238,9 +1224,9 @@ rxk_Listener(void)
 #elif defined(AFS_DARWIN_ENV)
     rxk_ListenerPid = current_proc()->p_pid;
 #endif
-#if defined(RX_ENABLE_LOCKS) && !defined(AFS_SUN5_ENV)
+#ifdef RX_ENABLE_LOCKS
     AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS && !AFS_SUN5_ENV */
+#endif /* RX_ENABLE_LOCKS */
     while (afs_termState != AFSOP_STOP_RXK_LISTENER) {
         /* See if a check for additional packets was issued */
         rx_CheckPackets();
@@ -1276,9 +1262,6 @@ rxk_Listener(void)
 #if defined(AFS_SUN5_ENV) || defined(AFS_FBSD_ENV)
     osi_rxWakeup(&rxk_ListenerPid);
 #endif
-#ifdef AFS_SUN5_ENV
-    AFS_GUNLOCK();
-#endif /* AFS_SUN5_ENV */
 }
 
 #if !defined(AFS_LINUX20_ENV) && !defined(AFS_SUN5_ENV) && !defined(AFS_DARWIN_ENV) && !defined(AFS_XBSD_ENV)