#include <afsconfig.h>
#include <afs/param.h>
-#ifndef KERNEL
-# include <roken.h>
-#endif /* KERNEL */
+#include <roken.h>
-#include <sys/types.h> /* fd_set on older platforms */
-#include <errno.h>
-#include <signal.h>
-#ifdef AFS_NT40_ENV
-# include <winsock2.h>
-#else
-# include <unistd.h> /* select() prototype */
-# include <sys/time.h> /* struct timeval, select() prototype */
-# ifndef FD_SET
-# include <sys/select.h> /* fd_set on newer platforms */
-# endif
-# include <sys/socket.h>
+#ifdef HAVE_SYS_FILE_H
# include <sys/file.h>
-# include <netdb.h>
-# include <sys/stat.h>
-# include <netinet/in.h>
-# include <net/if.h>
-# include <sys/ioctl.h>
-# include <sys/time.h>
#endif
+#ifndef AFS_PTHREAD_ENV
+
+#include <lwp.h>
+
#include "rx.h"
#include "rx_atomic.h"
#include "rx_globals.h"
+#include "rx_internal.h"
#include "rx_stats.h"
-#include <lwp.h>
+#ifdef AFS_NT40_ENV
+#include "rx_xmit_nt.h"
+#endif
#define MAXTHREADNAMELENGTH 64
rxi_ServerProc(threadID, newcall, &sock);
/* osi_Assert(sock != OSI_NULLSOCKET); */
}
- /* not reached */
- return NULL;
+ AFS_UNREACHED(return(NULL));
}
/* This is the server process request loop. The server process loop
/* osi_Assert(threadID != -1); */
/* osi_Assert(newcall != NULL); */
}
- /* not reached */
- return NULL;
+ AFS_UNREACHED(return(NULL));
}
/*
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);
+ int code;
+ code = recvmsg(socket, msg_p, flags);
+
+ if (code < 0) {
+ rxi_HandleSocketErrors(socket);
+ }
+
+ return code;
}
/*
int
rxi_Sendmsg(osi_socket socket, struct msghdr *msg_p, int flags)
{
+ int err = 0;
fd_set *sfds = (fd_set *) 0;
while (sendmsg(socket, msg_p, flags) == -1) {
- int err;
+
+#ifdef AFS_NT40_ENV
+ err = WSAGetLastError();
+#else
+ err = errno;
+#endif
+
if (rx_stats_active)
rx_atomic_inc(&rx_stats.sendSelects);
if (!(sfds = IOMGR_AllocFDSet())) {
(osi_Msg "rx failed to alloc fd_set: ");
perror("rx_sendmsg");
- return -1;
+ err = ENOMEM;
+ goto error;
}
FD_SET(socket, sfds);
}
-#if defined(HAVE_LINUX_ERRQUEUE_H) && defined(ADAPT_PMTU)
- while((rxi_HandleSocketError(socket)) > 0)
- ;
-#endif
#ifdef AFS_NT40_ENV
- if (WSAGetLastError())
+ if (err)
#elif defined(AFS_LINUX22_ENV)
/* linux unfortunately returns ECONNREFUSED if the target port
* is no longer in use */
/* and EAGAIN if a UDP checksum is incorrect */
- if (errno != EWOULDBLOCK && errno != ENOBUFS && errno != ECONNREFUSED
- && errno != EAGAIN)
+ if (err != EWOULDBLOCK && err != ENOBUFS && err != ECONNREFUSED
+ && err != EAGAIN)
#else
- if (errno != EWOULDBLOCK && errno != ENOBUFS)
+ if (err != EWOULDBLOCK && err != ENOBUFS)
#endif
{
(osi_Msg "rx failed to send packet: ");
perror("rx_sendmsg");
-#ifndef AFS_NT40_ENV
- if (errno > 0)
- return -errno;
+ goto error;
+ }
+ while ((err = select(
+#ifdef AFS_NT40_ENV
+ 0,
#else
- if (WSAGetLastError() > 0)
- return -WSAGetLastError();
+ socket + 1,
#endif
- return -1;
- }
- while ((err = select(socket + 1, 0, sfds, 0, 0)) != 1) {
+ 0, sfds, 0, 0)) != 1) {
if (err >= 0 || errno != EINTR)
osi_Panic("rxi_sendmsg: select error %d.%d", err, errno);
+ FD_ZERO(sfds);
+ FD_SET(socket, sfds);
}
}
if (sfds)
IOMGR_FreeFDSet(sfds);
return 0;
+
+ error:
+ if (sfds)
+ IOMGR_FreeFDSet(sfds);
+ if (err > 0)
+ return -err;
+ return -1;
}
+#endif