mirror of
https://git.openafs.org/openafs.git
synced 2025-01-31 21:47:45 +00:00
STABLE14-rx-send-error-code-propagation-20050915
* add a version of rxi_DebugPrint for Windows that uses OutputDebugString * migrate all printf statements to the dpf macro * stop masking the errors from rx_sendmsg() so that higher level functions can make decisions based upon the failure. * Windows reports EHOSTUNREACHABLE. Similar to Linux, if it is reported reset the send packet start time to 0 in order to immediately cause the server to be marked down. (cherry picked from commit 9ac9185b0feb87eff820963f83a6c861c49bdab5)
This commit is contained in:
parent
3f02d0f4be
commit
35bbe6c952
18
src/rx/rx.c
18
src/rx/rx.c
@ -6033,6 +6033,21 @@ rxi_DebugPrint(char *format, int a1, int a2, int a3, int a4, int a5, int a6,
|
|||||||
int a7, int a8, int a9, int a10, int a11, int a12, int a13,
|
int a7, int a8, int a9, int a10, int a11, int a12, int a13,
|
||||||
int a14, int a15)
|
int a14, int a15)
|
||||||
{
|
{
|
||||||
|
#ifdef AFS_NT40_ENV
|
||||||
|
char msg[512];
|
||||||
|
int len;
|
||||||
|
|
||||||
|
len = _snprintf(msg, sizeof(msg)-2,
|
||||||
|
format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
|
||||||
|
a11, a12, a13, a14, a15);
|
||||||
|
if (len > 0) {
|
||||||
|
if (msg[len-1] != '\n') {
|
||||||
|
msg[len] = '\n';
|
||||||
|
msg[len+1] = '\0';
|
||||||
|
}
|
||||||
|
OutputDebugString(msg);
|
||||||
|
}
|
||||||
|
#else
|
||||||
struct clock now;
|
struct clock now;
|
||||||
clock_GetTime(&now);
|
clock_GetTime(&now);
|
||||||
fprintf(rx_Log, " %u.%.3u:", (unsigned int)now.sec,
|
fprintf(rx_Log, " %u.%.3u:", (unsigned int)now.sec,
|
||||||
@ -6040,10 +6055,9 @@ rxi_DebugPrint(char *format, int a1, int a2, int a3, int a4, int a5, int a6,
|
|||||||
fprintf(rx_Log, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12,
|
fprintf(rx_Log, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12,
|
||||||
a13, a14, a15);
|
a13, a14, a15);
|
||||||
putc('\n', rx_Log);
|
putc('\n', rx_Log);
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef RXDEBUG
|
|
||||||
/*
|
/*
|
||||||
* This function is used to process the rx_stats structure that is local
|
* This function is used to process the rx_stats structure that is local
|
||||||
* to a process as well as an rx_stats structure received from a remote
|
* to a process as well as an rx_stats structure received from a remote
|
||||||
|
@ -47,7 +47,7 @@ void
|
|||||||
clock_Init(void)
|
clock_Init(void)
|
||||||
{
|
{
|
||||||
if (!QueryPerformanceFrequency(&rxi_clockFreq)) {
|
if (!QueryPerformanceFrequency(&rxi_clockFreq)) {
|
||||||
printf("No High Performance clock, exiting.\n");
|
OutputDebugString("No High Performance clock, exiting.\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,7 +169,7 @@ rx_getAllAddr(afs_int32 buffer[], int maxSize)
|
|||||||
while (next < lim) {
|
while (next < lim) {
|
||||||
ifm = (struct if_msghdr *)next;
|
ifm = (struct if_msghdr *)next;
|
||||||
if (ifm->ifm_type != RTM_IFINFO) {
|
if (ifm->ifm_type != RTM_IFINFO) {
|
||||||
printf("out of sync parsing NET_RT_IFLIST\n");
|
dpf(("out of sync parsing NET_RT_IFLIST\n"));
|
||||||
free(buf);
|
free(buf);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -204,8 +204,8 @@ rx_getAllAddr(afs_int32 buffer[], int maxSize)
|
|||||||
a = info.rti_info[RTAX_IFA];
|
a = info.rti_info[RTAX_IFA];
|
||||||
|
|
||||||
if (count >= maxSize) /* no more space */
|
if (count >= maxSize) /* no more space */
|
||||||
printf("Too many interfaces..ignoring 0x%x\n",
|
dpf(("Too many interfaces..ignoring 0x%x\n",
|
||||||
a->sin_addr.s_addr);
|
a->sin_addr.s_addr));
|
||||||
else
|
else
|
||||||
buffer[count++] = a->sin_addr.s_addr;
|
buffer[count++] = a->sin_addr.s_addr;
|
||||||
addrcount--;
|
addrcount--;
|
||||||
@ -253,7 +253,7 @@ rxi_getAllAddrMaskMtu(afs_int32 addrBuffer[], afs_int32 maskBuffer[],
|
|||||||
while (next < lim) {
|
while (next < lim) {
|
||||||
ifm = (struct if_msghdr *)next;
|
ifm = (struct if_msghdr *)next;
|
||||||
if (ifm->ifm_type != RTM_IFINFO) {
|
if (ifm->ifm_type != RTM_IFINFO) {
|
||||||
printf("out of sync parsing NET_RT_IFLIST\n");
|
dpf(("out of sync parsing NET_RT_IFLIST\n"));
|
||||||
free(buf);
|
free(buf);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -286,8 +286,8 @@ rxi_getAllAddrMaskMtu(afs_int32 addrBuffer[], afs_int32 maskBuffer[],
|
|||||||
|
|
||||||
if (a->sin_addr.s_addr != htonl(0x7f000001) ) {
|
if (a->sin_addr.s_addr != htonl(0x7f000001) ) {
|
||||||
if (count >= maxSize) { /* no more space */
|
if (count >= maxSize) { /* no more space */
|
||||||
printf("Too many interfaces..ignoring 0x%x\n",
|
dpf(("Too many interfaces..ignoring 0x%x\n",
|
||||||
a->sin_addr.s_addr);
|
a->sin_addr.s_addr));
|
||||||
} else {
|
} else {
|
||||||
struct ifreq ifr;
|
struct ifreq ifr;
|
||||||
|
|
||||||
@ -381,8 +381,8 @@ rx_getAllAddr_internal(afs_int32 buffer[], int maxSize, int loopbacks)
|
|||||||
continue; /* skip aliased loopbacks as well. */
|
continue; /* skip aliased loopbacks as well. */
|
||||||
}
|
}
|
||||||
if (count >= maxSize) /* no more space */
|
if (count >= maxSize) /* no more space */
|
||||||
printf("Too many interfaces..ignoring 0x%x\n",
|
dpf(("Too many interfaces..ignoring 0x%x\n",
|
||||||
a->sin_addr.s_addr);
|
a->sin_addr.s_addr));
|
||||||
else
|
else
|
||||||
buffer[count++] = a->sin_addr.s_addr;
|
buffer[count++] = a->sin_addr.s_addr;
|
||||||
}
|
}
|
||||||
@ -462,8 +462,8 @@ rxi_getAllAddrMaskMtu(afs_int32 addrBuffer[], afs_int32 maskBuffer[],
|
|||||||
continue; /* skip loopback address as well. */
|
continue; /* skip loopback address as well. */
|
||||||
|
|
||||||
if (count >= maxSize) { /* no more space */
|
if (count >= maxSize) { /* no more space */
|
||||||
printf("Too many interfaces..ignoring 0x%x\n",
|
dpf("Too many interfaces..ignoring 0x%x\n",
|
||||||
a->sin_addr.s_addr);
|
a->sin_addr.s_addr));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -507,7 +507,11 @@ EXT FILE *rx_debugFile; /* Set by the user to a stdio file for debugging output
|
|||||||
EXT FILE *rxevent_debugFile; /* Set to an stdio descriptor for event logging to that file */
|
EXT FILE *rxevent_debugFile; /* Set to an stdio descriptor for event logging to that file */
|
||||||
|
|
||||||
#define rx_Log rx_debugFile
|
#define rx_Log rx_debugFile
|
||||||
|
#ifdef AFS_NT40_ENV
|
||||||
|
#define dpf(args) rxi_DebugPrint args;
|
||||||
|
#else
|
||||||
#define dpf(args) if (rx_debugFile) rxi_DebugPrint args; else
|
#define dpf(args) if (rx_debugFile) rxi_DebugPrint args; else
|
||||||
|
#endif
|
||||||
#define rx_Log_event rxevent_debugFile
|
#define rx_Log_event rxevent_debugFile
|
||||||
|
|
||||||
EXT char *rx_packetTypes[RX_N_PACKET_TYPES] INIT(RX_PACKET_TYPES); /* Strings defined in rx.h */
|
EXT char *rx_packetTypes[RX_N_PACKET_TYPES] INIT(RX_PACKET_TYPES); /* Strings defined in rx.h */
|
||||||
|
@ -126,7 +126,7 @@ osi_Panic(msg, a1, a2, a3)
|
|||||||
if (!msg)
|
if (!msg)
|
||||||
msg = "Unknown AFS panic";
|
msg = "Unknown AFS panic";
|
||||||
|
|
||||||
printf(msg, a1, a2, a3);
|
dpf(msg, a1, a2, a3));
|
||||||
#ifdef AFS_LINUX24_ENV
|
#ifdef AFS_LINUX24_ENV
|
||||||
BUG();
|
BUG();
|
||||||
#else
|
#else
|
||||||
@ -316,7 +316,7 @@ MyPacketProc(char **ahandle, int asize)
|
|||||||
rx_stats.bogusPacketOnRead++;
|
rx_stats.bogusPacketOnRead++;
|
||||||
MUTEX_EXIT(&rx_stats_mutex);
|
MUTEX_EXIT(&rx_stats_mutex);
|
||||||
/* I DON"T LIKE THIS PRINTF -- PRINTFS MAKE THINGS VERY VERY SLOOWWW */
|
/* I DON"T LIKE THIS PRINTF -- PRINTFS MAKE THINGS VERY VERY SLOOWWW */
|
||||||
printf("rx: packet dropped: bad ulen=%d\n", asize);
|
dpf(("rx: packet dropped: bad ulen=%d\n", asize));
|
||||||
tp = NULL;
|
tp = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -495,7 +495,7 @@ shutdown_rxkernel(void)
|
|||||||
rxk_shutdownPorts();
|
rxk_shutdownPorts();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
printf("shutdown_rxkernel: no udp proto");
|
dpf(("shutdown_rxkernel: no udp proto"));
|
||||||
}
|
}
|
||||||
#endif /* !AIX && !SUN && !NCR && !UKERNEL */
|
#endif /* !AIX && !SUN && !NCR && !UKERNEL */
|
||||||
|
|
||||||
@ -864,7 +864,7 @@ rxk_NewSocketHost(afs_uint32 ahost, short aport)
|
|||||||
code = sobind(newSocket, (struct sockaddr *)&myaddr);
|
code = sobind(newSocket, (struct sockaddr *)&myaddr);
|
||||||
#endif
|
#endif
|
||||||
if (code) {
|
if (code) {
|
||||||
printf("sobind fails (%d)\n", (int)code);
|
dpf(("sobind fails (%d)\n", (int)code));
|
||||||
soclose(newSocket);
|
soclose(newSocket);
|
||||||
AFS_GLOCK();
|
AFS_GLOCK();
|
||||||
goto bad;
|
goto bad;
|
||||||
@ -891,7 +891,7 @@ rxk_NewSocketHost(afs_uint32 ahost, short aport)
|
|||||||
code = sobind(newSocket, nam);
|
code = sobind(newSocket, nam);
|
||||||
#endif
|
#endif
|
||||||
if (code) {
|
if (code) {
|
||||||
printf("sobind fails (%d)\n", (int)code);
|
dpf(("sobind fails (%d)\n", (int)code));
|
||||||
soclose(newSocket);
|
soclose(newSocket);
|
||||||
#ifndef AFS_SGI65_ENV
|
#ifndef AFS_SGI65_ENV
|
||||||
m_freem(nam);
|
m_freem(nam);
|
||||||
|
@ -1472,6 +1472,7 @@ osi_NetSend(osi_socket socket, void *addr, struct iovec *dvec, int nvecs,
|
|||||||
int length, int istack)
|
int length, int istack)
|
||||||
{
|
{
|
||||||
struct msghdr msg;
|
struct msghdr msg;
|
||||||
|
int ret;
|
||||||
|
|
||||||
memset(&msg, 0, sizeof(msg));
|
memset(&msg, 0, sizeof(msg));
|
||||||
msg.msg_iov = dvec;
|
msg.msg_iov = dvec;
|
||||||
@ -1479,9 +1480,9 @@ osi_NetSend(osi_socket socket, void *addr, struct iovec *dvec, int nvecs,
|
|||||||
msg.msg_name = addr;
|
msg.msg_name = addr;
|
||||||
msg.msg_namelen = sizeof(struct sockaddr_in);
|
msg.msg_namelen = sizeof(struct sockaddr_in);
|
||||||
|
|
||||||
rxi_Sendmsg(socket, &msg, 0);
|
ret = rxi_Sendmsg(socket, &msg, 0);
|
||||||
|
|
||||||
return 0;
|
return ret;
|
||||||
}
|
}
|
||||||
#elif !defined(UKERNEL)
|
#elif !defined(UKERNEL)
|
||||||
/*
|
/*
|
||||||
@ -2134,6 +2135,15 @@ rxi_SendPacket(struct rx_call *call, struct rx_connection *conn,
|
|||||||
clock_Addmsec(&(p->retryTime),
|
clock_Addmsec(&(p->retryTime),
|
||||||
10 + (((afs_uint32) p->backoff) << 8));
|
10 + (((afs_uint32) p->backoff) << 8));
|
||||||
|
|
||||||
|
#ifdef AFS_NT40_ENV
|
||||||
|
/* Windows is nice -- it can tell us right away that we cannot
|
||||||
|
* reach this recipient by returning an WSAEHOSTUNREACH error
|
||||||
|
* code. So, when this happens let's "down" the host NOW so
|
||||||
|
* we don't sit around waiting for this host to timeout later.
|
||||||
|
*/
|
||||||
|
if (call && code == -1 && errno == WSAEHOSTUNREACH)
|
||||||
|
call->lastReceiveTime = 0;
|
||||||
|
#endif
|
||||||
#if defined(KERNEL) && defined(AFS_LINUX20_ENV)
|
#if defined(KERNEL) && defined(AFS_LINUX20_ENV)
|
||||||
/* Linux is nice -- it can tell us right away that we cannot
|
/* Linux is nice -- it can tell us right away that we cannot
|
||||||
* reach this recipient by returning an ENETUNREACH error
|
* reach this recipient by returning an ENETUNREACH error
|
||||||
|
@ -96,7 +96,7 @@ server_entry(void *argp)
|
|||||||
{
|
{
|
||||||
void (*server_proc) () = (void (*)())argp;
|
void (*server_proc) () = (void (*)())argp;
|
||||||
server_proc();
|
server_proc();
|
||||||
printf("rx_pthread.c: server_entry: Server proc returned unexpectedly\n");
|
dpf(("rx_pthread.c: server_entry: Server proc returned unexpectedly\n"));
|
||||||
exit(1);
|
exit(1);
|
||||||
return (void *)0;
|
return (void *)0;
|
||||||
}
|
}
|
||||||
@ -112,13 +112,13 @@ rxi_StartServerProc(void (*proc) (void), int stacksize)
|
|||||||
AFS_SIGSET_DECL;
|
AFS_SIGSET_DECL;
|
||||||
|
|
||||||
if (pthread_attr_init(&tattr) != 0) {
|
if (pthread_attr_init(&tattr) != 0) {
|
||||||
printf("Unable to Create Rx server thread (pthread_attr_init)\n");
|
dpf(("Unable to Create Rx server thread (pthread_attr_init)\n"));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED) != 0) {
|
if (pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED) != 0) {
|
||||||
printf
|
dpf
|
||||||
("Unable to Create Rx server thread (pthread_attr_setdetachstate)\n");
|
(("Unable to Create Rx server thread (pthread_attr_setdetachstate)\n"));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ rxi_StartServerProc(void (*proc) (void), int stacksize)
|
|||||||
*/
|
*/
|
||||||
AFS_SIGSET_CLEAR();
|
AFS_SIGSET_CLEAR();
|
||||||
if (pthread_create(&thread, &tattr, server_entry, (void *)proc) != 0) {
|
if (pthread_create(&thread, &tattr, server_entry, (void *)proc) != 0) {
|
||||||
printf("Unable to Create Rx server thread\n");
|
dpf(("Unable to Create Rx server thread\n"));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
AFS_SIGSET_RESTORE();
|
AFS_SIGSET_RESTORE();
|
||||||
@ -220,7 +220,7 @@ rxi_ListenerProc(int sock, int *tnop, struct rx_call **newcallp)
|
|||||||
} else {
|
} else {
|
||||||
if (!(p = rxi_AllocPacket(RX_PACKET_CLASS_RECEIVE))) {
|
if (!(p = rxi_AllocPacket(RX_PACKET_CLASS_RECEIVE))) {
|
||||||
/* Could this happen with multiple socket listeners? */
|
/* Could this happen with multiple socket listeners? */
|
||||||
printf("rxi_Listener: no packets!"); /* Shouldn't happen */
|
dpf(("rxi_Listener: no packets!")); /* Shouldn't happen */
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -323,21 +323,21 @@ rxi_StartListener(void)
|
|||||||
AFS_SIGSET_DECL;
|
AFS_SIGSET_DECL;
|
||||||
|
|
||||||
if (pthread_attr_init(&tattr) != 0) {
|
if (pthread_attr_init(&tattr) != 0) {
|
||||||
printf
|
dpf
|
||||||
("Unable to create Rx event handling thread (pthread_attr_init)\n");
|
(("Unable to create Rx event handling thread (pthread_attr_init)\n"));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED) != 0) {
|
if (pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED) != 0) {
|
||||||
printf
|
dpf
|
||||||
("Unable to create Rx event handling thread (pthread_attr_setdetachstate)\n");
|
(("Unable to create Rx event handling thread (pthread_attr_setdetachstate)\n"));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
AFS_SIGSET_CLEAR();
|
AFS_SIGSET_CLEAR();
|
||||||
if (pthread_create(&event_handler_thread, &tattr, event_handler, NULL) !=
|
if (pthread_create(&event_handler_thread, &tattr, event_handler, NULL) !=
|
||||||
0) {
|
0) {
|
||||||
printf("Unable to create Rx event handling thread\n");
|
dpf(("Unable to create Rx event handling thread\n"));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
MUTEX_ENTER(&rx_stats_mutex);
|
MUTEX_ENTER(&rx_stats_mutex);
|
||||||
@ -363,20 +363,20 @@ rxi_Listen(osi_socket sock)
|
|||||||
AFS_SIGSET_DECL;
|
AFS_SIGSET_DECL;
|
||||||
|
|
||||||
if (pthread_attr_init(&tattr) != 0) {
|
if (pthread_attr_init(&tattr) != 0) {
|
||||||
printf
|
dpf
|
||||||
("Unable to create socket listener thread (pthread_attr_init)\n");
|
(("Unable to create socket listener thread (pthread_attr_init)\n"));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED) != 0) {
|
if (pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED) != 0) {
|
||||||
printf
|
dpf
|
||||||
("Unable to create socket listener thread (pthread_attr_setdetachstate)\n");
|
(("Unable to create socket listener thread (pthread_attr_setdetachstate)\n"));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
AFS_SIGSET_CLEAR();
|
AFS_SIGSET_CLEAR();
|
||||||
if (pthread_create(&thread, &tattr, rx_ListenerProc, (void *)sock) != 0) {
|
if (pthread_create(&thread, &tattr, rx_ListenerProc, (void *)sock) != 0) {
|
||||||
printf("Unable to create socket listener thread\n");
|
dpf(("Unable to create socket listener thread\n"));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
MUTEX_ENTER(&rx_stats_mutex);
|
MUTEX_ENTER(&rx_stats_mutex);
|
||||||
@ -415,8 +415,9 @@ rxi_Sendmsg(osi_socket socket, struct msghdr *msg_p, int flags)
|
|||||||
#else
|
#else
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
#endif
|
#endif
|
||||||
printf("rxi_sendmsg failed, error %d\n", errno);
|
dpf(("rxi_sendmsg failed, error %d\n", errno));
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -139,12 +139,15 @@ sendmsg(int socket, struct msghdr *msgP, int flags)
|
|||||||
case WSAEWOULDBLOCK:
|
case WSAEWOULDBLOCK:
|
||||||
errno = WSAEWOULDBLOCK;
|
errno = WSAEWOULDBLOCK;
|
||||||
break;
|
break;
|
||||||
|
case WSAEHOSTUNREACH:
|
||||||
|
errno = WSAEHOSTUNREACH;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
errno = EIO;
|
errno = EIO;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
code = -1;
|
code = -1;
|
||||||
}
|
} else
|
||||||
#endif /* AFS_NT40_ENV */
|
#endif /* AFS_NT40_ENV */
|
||||||
|
|
||||||
if (code < size) {
|
if (code < size) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user