Build fix - pre-processor typos in rx_lwp.c and rx_pthread.c
[openafs.git] / src / rx / rx_lwp.c
index 51c923d..2366cbc 100644 (file)
@@ -21,8 +21,6 @@
 #include <afsconfig.h>
 #include <afs/param.h>
 
-RCSID
-    ("$Header$");
 
 # include <sys/types.h>                /* fd_set on older platforms */
 # include <errno.h>
@@ -50,9 +48,6 @@ RCSID
 
 #define MAXTHREADNAMELENGTH 64
 
-extern int (*registerProgram) ();
-extern int (*swapNameProgram) ();
-
 int debugSelectFailure;                /* # of times select failed */
 
 /*
@@ -75,7 +70,7 @@ rxi_Wakeup(void *addr)
 }
 
 PROCESS rx_listenerPid = 0;    /* LWP process id of socket listener process */
-static int rx_ListenerProc(void *dummy);
+static void* rx_ListenerProc(void *dummy);
 
 /*
  * Delay the current thread the specified number of seconds.
@@ -119,14 +114,14 @@ rxi_InitializeThreadSupport(void)
 }
 
 void
-rxi_StartServerProc(void (*proc) (void), int stacksize)
+rxi_StartServerProc(void *(*proc) (void *), int stacksize)
 {
     PROCESS scratchPid;
     static int number = 0;
     char name[32];
 
     sprintf(name, "srv_%d", ++number);
-    LWP_CreateProcess((int (*)(void *))proc, stacksize, RX_PROCESS_PRIORITY, (void *)0,
+    LWP_CreateProcess(proc, stacksize, RX_PROCESS_PRIORITY, NULL,
                      "rx_ServerProc", &scratchPid);
     if (registerProgram)
        (*registerProgram) (scratchPid, name);
@@ -138,7 +133,7 @@ rxi_StartListener(void)
     /* Priority of listener should be high, so it can keep conns alive */
 #define        RX_LIST_STACK   24000
     LWP_CreateProcess(rx_ListenerProc, RX_LIST_STACK, LWP_MAX_PRIORITY,
-                     (void *)0, "rx_Listener", &rx_listenerPid);
+                     NULL, "rx_Listener", &rx_listenerPid);
     if (registerProgram)
        (*registerProgram) (rx_listenerPid, "listener");
 }
@@ -163,9 +158,9 @@ rxi_StartListener(void)
 static void
 rxi_ListenerProc(fd_set * rfds, int *tnop, struct rx_call **newcallp)
 {
-    struct sockaddr_storage saddr;
-    int slen;
-    register struct rx_packet *p = (struct rx_packet *)0;
+    afs_uint32 host;
+    u_short port;
+    struct rx_packet *p = (struct rx_packet *)0;
     osi_socket socket;
     struct clock cv;
     afs_int32 nextPollTime;    /* time to next poll FD before sleeping */
@@ -274,17 +269,16 @@ rxi_ListenerProc(fd_set * rfds, int *tnop, struct rx_call **newcallp)
 #ifdef AFS_NT40_ENV
            for (i = 0; p && i < rfds->fd_count; i++) {
                socket = rfds->fd_array[i];
-               slen = sizeof(saddr);
-               if (rxi_ReadPacket(socket, p, &saddr, &slen)) {
+               if (rxi_ReadPacket(socket, p, &host, &port)) {
                    *newcallp = NULL;
-                   p = rxi_ReceivePacket(p, socket, &saddr, slen, tnop,
+                   p = rxi_ReceivePacket(p, socket, host, port, tnop,
                                          newcallp);
                    if (newcallp && *newcallp) {
                        if (p) {
                            rxi_FreePacket(p);
                        }
                        if (swapNameProgram) {
-                           (*swapNameProgram) (rx_listenerPid, &name, 0);
+                           (*swapNameProgram) (rx_listenerPid, name, 0);
                            rx_listenerPid = 0;
                        }
                        return;
@@ -296,16 +290,15 @@ rxi_ListenerProc(fd_set * rfds, int *tnop, struct rx_call **newcallp)
                 p && socket <= rx_maxSocketNumber; socket++) {
                if (!FD_ISSET(socket, rfds))
                    continue;
-               slen = sizeof(saddr);
-               if (rxi_ReadPacket(socket, p, &saddr, &slen)) {
-                   p = rxi_ReceivePacket(p, socket, &saddr, slen, tnop,
+               if (rxi_ReadPacket(socket, p, &host, &port)) {
+                   p = rxi_ReceivePacket(p, socket, host, port, tnop,
                                          newcallp);
                    if (newcallp && *newcallp) {
                        if (p) {
                            rxi_FreePacket(p);
                        }
                        if (swapNameProgram) {
-                           (*swapNameProgram) (rx_listenerPid, &name, 0);
+                           (*swapNameProgram) (rx_listenerPid, name, 0);
                            rx_listenerPid = 0;
                        }
                        return;
@@ -322,7 +315,7 @@ rxi_ListenerProc(fd_set * rfds, int *tnop, struct rx_call **newcallp)
 /* This is the listener process request loop. The listener process loop
  * becomes a server thread when rxi_ListenerProc returns, and stays
  * server thread until rxi_ServerProc returns. */
-static int
+static void *
 rx_ListenerProc(void *dummy)
 {
     int threadID;
@@ -345,13 +338,14 @@ rx_ListenerProc(void *dummy)
        /* assert(sock != OSI_NULLSOCKET); */
     }
     /* not reached */
+    return NULL;
 }
 
 /* This is the server process request loop. The server process loop
  * becomes a listener thread when rxi_ServerProc returns, and stays
  * listener thread until rxi_ListenerProc returns. */
-void
-rx_ServerProc(void)
+void *
+rx_ServerProc(void * unused)
 {
     osi_socket sock;
     int threadID;
@@ -378,6 +372,7 @@ rx_ServerProc(void)
        /* assert(newcall != NULL); */
     }
     /* not reached */
+    return NULL;
 }
 
 /*
@@ -393,19 +388,11 @@ rxi_Listen(osi_socket sock)
      * Put the socket into non-blocking mode so that rx_Listener
      * can do a polling read before entering select
      */
-#ifndef AFS_DJGPP_ENV
     if (fcntl(sock, F_SETFL, FNDELAY) == -1) {
        perror("fcntl");
        (osi_Msg "rxi_Listen: unable to set non-blocking mode on socket\n");
        return -1;
     }
-#else
-    if (__djgpp_set_socket_blocking_mode(sock, 1) < 0) {
-       perror("__djgpp_set_socket_blocking_mode");
-       (osi_Msg "rxi_Listen: unable to set non-blocking mode on socket\n");
-       return -1;
-    }
-#endif /* AFS_DJGPP_ENV */
 
     if (sock > FD_SETSIZE - 1) {
        (osi_Msg "rxi_Listen: socket descriptor > (FD_SETSIZE-1) = %d\n",
@@ -428,6 +415,10 @@ rxi_Listen(osi_socket sock)
 int
 rxi_Recvmsg(osi_socket socket, struct msghdr *msg_p, int flags)
 {
+#if defined(HAVE_LINUX_ERRQUEUE_H) && defined(ADAPT_PMTU)
+    while((rxi_HandleSocketError(socket)) > 0)
+       ;
+#endif
     return recvmsg(socket, msg_p, flags);
 }
 
@@ -447,12 +438,16 @@ rxi_Sendmsg(osi_socket socket, struct msghdr *msg_p, int flags)
            if (!(sfds = IOMGR_AllocFDSet())) {
                (osi_Msg "rx failed to alloc fd_set: ");
                perror("rx_sendmsg");
-               return 3;
+               return -1;
            }
            FD_SET(socket, sfds);
        }
+#if defined(HAVE_LINUX_ERRQUEUE_H) && defined(ADAPT_PMTU)
+       while((rxi_HandleSocketError(socket)) > 0)
+         ;
+#endif
 #ifdef AFS_NT40_ENV
-       if (errno)
+       if (WSAGetLastError())
 #elif defined(AFS_LINUX22_ENV)
        /* linux unfortunately returns ECONNREFUSED if the target port
         * is no longer in use */
@@ -465,7 +460,14 @@ rxi_Sendmsg(osi_socket socket, struct msghdr *msg_p, int flags)
        {
            (osi_Msg "rx failed to send packet: ");
            perror("rx_sendmsg");
-           return 3;
+#ifndef AFS_NT40_ENV
+            if (errno > 0)
+              return -errno;
+#else
+            if (WSAGetLastError() > 0)
+              return -WSAGetLastError();
+#endif
+           return -1;
        }
        while ((err = select(socket + 1, 0, sfds, 0, 0)) != 1) {
            if (err >= 0 || errno != EINTR)