aboutsummaryrefslogtreecommitdiff
path: root/sunrpc
diff options
context:
space:
mode:
Diffstat (limited to 'sunrpc')
-rw-r--r--sunrpc/svc.c10
-rw-r--r--sunrpc/svc_tcp.c8
-rw-r--r--sunrpc/svc_unix.c8
3 files changed, 24 insertions, 2 deletions
diff --git a/sunrpc/svc.c b/sunrpc/svc.c
index 917e9a3..3ed6cee 100644
--- a/sunrpc/svc.c
+++ b/sunrpc/svc.c
@@ -545,6 +545,13 @@ svc_getreq_common (const int fd)
}
libc_hidden_nolink_sunrpc (svc_getreq_common, GLIBC_2_2)
+void
+__svc_wait_on_error (void)
+{
+ struct timespec ts = { .tv_sec = 0, .tv_nsec = 50000000 };
+ __nanosleep (&ts, NULL);
+}
+
/* If there are no file descriptors available, then accept will fail.
We want to delay here so the connection request can be dequeued;
otherwise we can bounce between polling and accepting, never giving the
@@ -555,8 +562,7 @@ __svc_accept_failed (void)
{
if (errno == EMFILE)
{
- struct timespec ts = { .tv_sec = 0, .tv_nsec = 50000000 };
- __nanosleep (&ts, NULL);
+ __svc_wait_on_error ();
}
}
diff --git a/sunrpc/svc_tcp.c b/sunrpc/svc_tcp.c
index efbdd22..12de60f 100644
--- a/sunrpc/svc_tcp.c
+++ b/sunrpc/svc_tcp.c
@@ -271,6 +271,14 @@ again:
* make a new transporter (re-uses xprt)
*/
xprt = makefd_xprt (sock, r->sendsize, r->recvsize);
+
+ /* If we are out of memory, makefd_xprt has already dumped an error. */
+ if (xprt == NULL)
+ {
+ __svc_wait_on_error ();
+ return FALSE;
+ }
+
memcpy (&xprt->xp_raddr, &addr, sizeof (addr));
xprt->xp_addrlen = len;
return FALSE; /* there is never an rpc msg to be processed */
diff --git a/sunrpc/svc_unix.c b/sunrpc/svc_unix.c
index e01afea..3decea4 100644
--- a/sunrpc/svc_unix.c
+++ b/sunrpc/svc_unix.c
@@ -270,6 +270,14 @@ again:
memset (&in_addr, '\0', sizeof (in_addr));
in_addr.sin_family = AF_UNIX;
xprt = makefd_xprt (sock, r->sendsize, r->recvsize);
+
+ /* If we are out of memory, makefd_xprt has already dumped an error. */
+ if (xprt == NULL)
+ {
+ __svc_wait_on_error ();
+ return FALSE;
+ }
+
memcpy (&xprt->xp_raddr, &in_addr, sizeof (in_addr));
xprt->xp_addrlen = len;
return FALSE; /* there is never an rpc msg to be processed */