2011-07-07 16:52:52 +02:00
|
|
|
For details see:
|
2011-07-04 15:26:19 +02:00
|
|
|
http://sourceware.org/bugzilla/show_bug.cgi?id=5379
|
|
|
|
|
2011-07-07 16:52:52 +02:00
|
|
|
--- sunrpc/clnt_udp.c.orig 2008-10-10 14:42:04.000000000 -0400
|
|
|
|
+++ sunrpc/clnt_udp.c 2008-10-10 16:15:33.000000000 -0400
|
|
|
|
@@ -38,6 +38,7 @@
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
+#include <stdint.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <libintl.h>
|
|
|
|
#include <rpc/rpc.h>
|
|
|
|
@@ -266,8 +267,7 @@
|
2009-02-20 08:46:43 +01:00
|
|
|
int inlen;
|
|
|
|
socklen_t fromlen;
|
|
|
|
struct pollfd fd;
|
2011-07-07 16:52:52 +02:00
|
|
|
- int milliseconds = (cu->cu_wait.tv_sec * 1000) +
|
|
|
|
- (cu->cu_wait.tv_usec / 1000);
|
|
|
|
+ int milliseconds;
|
|
|
|
struct sockaddr_in from;
|
|
|
|
struct rpc_msg reply_msg;
|
|
|
|
XDR reply_xdrs;
|
|
|
|
@@ -275,6 +275,8 @@
|
|
|
|
bool_t ok;
|
|
|
|
int nrefreshes = 2; /* number of times to refresh cred */
|
|
|
|
struct timeval timeout;
|
|
|
|
+ uint64_t start_time, end_time;
|
|
|
|
+ struct timeval tmp_tv;
|
|
|
|
int anyup; /* any network interface up */
|
|
|
|
|
|
|
|
if (cu->cu_total.tv_usec == -1)
|
|
|
|
@@ -332,6 +334,18 @@
|
|
|
|
fd.fd = cu->cu_sock;
|
|
|
|
fd.events = POLLIN;
|
2009-02-20 08:46:43 +01:00
|
|
|
anyup = 0;
|
2011-07-07 16:52:52 +02:00
|
|
|
+
|
|
|
|
+ poll_again:
|
|
|
|
+ milliseconds = (cu->cu_wait.tv_sec * 1000) +
|
|
|
|
+ (cu->cu_wait.tv_usec / 1000);
|
|
|
|
+ if (gettimeofday(&tmp_tv, NULL) != 0)
|
|
|
|
+ {
|
|
|
|
+ /* XXX: What is the correct return here? */
|
|
|
|
+ return (cu->cu_error.re_status = RPC_CANTRECV);
|
|
|
|
+ }
|
|
|
|
+ start_time = (uint64_t)tmp_tv.tv_sec * 1000 +
|
|
|
|
+ (uint64_t)tmp_tv.tv_usec / 1000;
|
|
|
|
+
|
2009-02-20 08:46:43 +01:00
|
|
|
for (;;)
|
|
|
|
{
|
2011-07-07 16:52:52 +02:00
|
|
|
switch (__poll (&fd, 1, milliseconds))
|
|
|
|
@@ -364,7 +378,28 @@
|
|
|
|
*/
|
2009-02-20 08:46:43 +01:00
|
|
|
case -1:
|
2011-07-07 16:52:52 +02:00
|
|
|
if (errno == EINTR)
|
2009-02-20 08:46:43 +01:00
|
|
|
- continue;
|
2011-07-07 16:52:52 +02:00
|
|
|
+ {
|
|
|
|
+ /* Decrement time already spent polling. */
|
|
|
|
+ if (gettimeofday(&tmp_tv, NULL) != 0)
|
|
|
|
+ {
|
2009-02-20 08:46:43 +01:00
|
|
|
+ return (cu->cu_error.re_status = RPC_CANTRECV);
|
2011-07-07 16:52:52 +02:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ end_time = (uint64_t)tmp_tv.tv_sec * 1000 +
|
|
|
|
+ (uint64_t)tmp_tv.tv_usec / 1000;
|
2009-02-20 08:46:43 +01:00
|
|
|
+
|
2011-07-07 16:52:52 +02:00
|
|
|
+ if ((end_time - start_time) > (uint64_t)milliseconds)
|
|
|
|
+ {
|
|
|
|
+ milliseconds = 0;
|
|
|
|
+ }
|
2009-02-20 08:46:43 +01:00
|
|
|
+ else
|
2011-07-07 16:52:52 +02:00
|
|
|
+ {
|
|
|
|
+ milliseconds -= (int)(end_time - start_time);
|
|
|
|
+ }
|
|
|
|
+ start_time = end_time;
|
2009-02-20 08:46:43 +01:00
|
|
|
+
|
2011-07-07 16:52:52 +02:00
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
cu->cu_error.re_errno = errno;
|
|
|
|
return (cu->cu_error.re_status = RPC_CANTRECV);
|
|
|
|
}
|
|
|
|
@@ -420,19 +455,19 @@
|
|
|
|
if (inlen < 0)
|
|
|
|
{
|
|
|
|
if (errno == EWOULDBLOCK)
|
|
|
|
- continue;
|
|
|
|
+ goto poll_again;
|
2009-02-20 08:46:43 +01:00
|
|
|
cu->cu_error.re_errno = errno;
|
|
|
|
return (cu->cu_error.re_status = RPC_CANTRECV);
|
|
|
|
}
|
2011-07-07 16:52:52 +02:00
|
|
|
if (inlen < 4)
|
|
|
|
- continue;
|
|
|
|
+ goto poll_again;
|
|
|
|
|
|
|
|
/* see if reply transaction id matches sent id.
|
|
|
|
Don't do this if we only wait for a replay */
|
|
|
|
if (xargs != NULL
|
|
|
|
&& (*((u_int32_t *) (cu->cu_inbuf))
|
|
|
|
!= *((u_int32_t *) (cu->cu_outbuf))))
|
|
|
|
- continue;
|
|
|
|
+ goto poll_again;
|
|
|
|
/* we now assume we have the proper reply */
|
|
|
|
break;
|
|
|
|
}
|