Move PMTU header block to top of file
[openafs.git] / src / rx / rx_user.c
index 78f86fd..0516457 100644 (file)
@@ -9,11 +9,11 @@
 
 /* rx_user.c contains routines specific to the user space UNIX implementation of rx */
 
+/* rxi_syscall is currently not prototyped */
+
 #include <afsconfig.h>
 #include <afs/param.h>
 
-RCSID
-    ("$Header$");
 
 # include <sys/types.h>
 # include <errno.h>
@@ -30,6 +30,7 @@ RCSID
 # include <sys/time.h>
 # include <net/if.h>
 # include <sys/ioctl.h>
+# include <unistd.h>
 #endif
 # include <fcntl.h>
 #if !defined(AFS_AIX_ENV) && !defined(AFS_NT40_ENV) 
@@ -45,10 +46,17 @@ RCSID
 #define IPPORT_USERRESERVED 5000
 # endif
 
+#if defined(HAVE_LINUX_ERRQUEUE_H) && defined(ADAPT_PMTU)
+#include <linux/types.h>
+#include <linux/errqueue.h>
+#ifndef IP_MTU
+#define IP_MTU 14
+#endif
+#endif
+
 #ifndef AFS_NT40_ENV
 # include <sys/time.h>
 #endif
-# include "rx_internal.h"
 # include "rx.h"
 # include "rx_globals.h"
 
@@ -60,9 +68,9 @@ RCSID
  * Inited
  */
 
-pthread_mutex_t rx_if_init_mutex;
-#define LOCK_IF_INIT assert(pthread_mutex_lock(&rx_if_init_mutex)==0)
-#define UNLOCK_IF_INIT assert(pthread_mutex_unlock(&rx_if_init_mutex)==0)
+afs_kmutex_t rx_if_init_mutex;
+#define LOCK_IF_INIT MUTEX_ENTER(&rx_if_init_mutex)
+#define UNLOCK_IF_INIT MUTEX_EXIT(&rx_if_init_mutex)
 
 /*
  * The rx_if_mutex mutex protects the following global variables:
@@ -71,9 +79,9 @@ pthread_mutex_t rx_if_init_mutex;
  * myNetMasks
  */
 
-pthread_mutex_t rx_if_mutex;
-#define LOCK_IF assert(pthread_mutex_lock(&rx_if_mutex)==0)
-#define UNLOCK_IF assert(pthread_mutex_unlock(&rx_if_mutex)==0)
+afs_kmutex_t rx_if_mutex;
+#define LOCK_IF MUTEX_ENTER(&rx_if_mutex)
+#define UNLOCK_IF MUTEX_EXIT(&rx_if_mutex)
 #else
 #define LOCK_IF_INIT
 #define UNLOCK_IF_INIT
@@ -103,13 +111,6 @@ rxi_GetHostUDPSocket(u_int ahost, u_short port)
     int pmtu=IP_PMTUDISC_DONT;
 #endif
 #endif
-#if defined(HAVE_LINUX_ERRQUEUE_H) && defined(ADAPT_PMTU)
-#include <linux/types.h>
-#include <linux/errqueue.h>
-#ifndef IP_MTU
-#define IP_MTU 14
-#endif
-#endif
 
 #if !defined(AFS_NT40_ENV) 
     if (ntohs(port) >= IPPORT_RESERVED && ntohs(port) < IPPORT_USERRESERVED) {
@@ -130,6 +131,10 @@ rxi_GetHostUDPSocket(u_int ahost, u_short port)
        goto error;
     }
 
+#ifdef AFS_NT40_ENV
+    rxi_xmit_init(socketFd);
+#endif /* AFS_NT40_ENV */
+
     taddr.sin_addr.s_addr = ahost;
     taddr.sin_family = AF_INET;
     taddr.sin_port = (u_short) port;
@@ -195,9 +200,11 @@ rxi_GetHostUDPSocket(u_int ahost, u_short port)
        if (!greedy)
            (osi_Msg "%s*WARNING* Unable to increase buffering on socket\n",
             name);
-       MUTEX_ENTER(&rx_stats_mutex);
-       rx_stats.socketGreedy = greedy;
-       MUTEX_EXIT(&rx_stats_mutex);
+        if (rx_stats_active) {
+            MUTEX_ENTER(&rx_stats_mutex);
+            rx_stats.socketGreedy = greedy;
+            MUTEX_EXIT(&rx_stats_mutex);
+        }
     }
 
 #ifdef AFS_LINUX22_ENV
@@ -455,14 +462,12 @@ fudge_netmask(afs_uint32 addr)
 
 #if !defined(AFS_AIX_ENV) && !defined(AFS_NT40_ENV) && !defined(AFS_LINUX20_ENV) 
 int
-rxi_syscall(a3, a4, a5)
-     afs_uint32 a3, a4;
-     void *a5;
+rxi_syscall(afs_uint32 a3, afs_uint32 a4, void *a5)
 {
     afs_uint32 rcode;
-    void (*old) ();
+    void (*old) (int);
 
-    old = (void (*)())signal(SIGSYS, SIG_IGN);
+    old = signal(SIGSYS, SIG_IGN);
 
 #if defined(AFS_SGI_ENV)
     rcode = afs_syscall(a3, a4, a5);
@@ -696,6 +701,8 @@ rxi_InitPeerParams(struct rx_peer *pp)
     struct sockaddr_in addr;
 #endif
 
+
+
     LOCK_IF_INIT;
     if (!Inited) {
        UNLOCK_IF_INIT;
@@ -712,14 +719,14 @@ rxi_InitPeerParams(struct rx_peer *pp)
     /* try to second-guess IP, and identify which link is most likely to
      * be used for traffic to/from this host. */
     ppaddr = ntohl(pp->host);
-    
+
     pp->ifMTU = 0;
     pp->timeout.sec = 2;
-    pp->rateFlag = 2;         /* start timing after two full packets */
+    pp->rateFlag = 2;          /* start timing after two full packets */
     /* I don't initialize these, because I presume they are bzero'd... 
      * pp->burstSize pp->burst pp->burstWait.sec pp->burstWait.usec
      * pp->timeout.usec */
-    
+
     LOCK_IF;
     for (ix = 0; ix < rxi_numNetAddrs; ++ix) {
        if ((rxi_NetAddrs[ix] & myNetMasks[ix]) == (ppaddr & myNetMasks[ix])) {
@@ -735,7 +742,7 @@ rxi_InitPeerParams(struct rx_peer *pp)
        }
     }
     UNLOCK_IF;
-    if (!pp->ifMTU) {         /* not local */
+    if (!pp->ifMTU) {          /* not local */
        pp->timeout.sec = 3;
        pp->ifMTU = MIN(rx_MyMaxSendSize, RX_REMOTE_PACKET_SIZE);
     }