diff options
author | Jeff Law <law@redhat.com> | 2012-11-28 14:12:28 -0700 |
---|---|---|
committer | Jeff Law <law@redhat.com> | 2012-11-28 14:16:12 -0700 |
commit | 14bc93a967e62abf8cf2704725b6f76619399f83 (patch) | |
tree | 80ddd44c7357253f59d6477ced8266856ee9d247 /sunrpc/svc.c | |
parent | b54eb3cb0a4325975d9b82709865a055bc8da910 (diff) | |
download | glibc-14bc93a967e62abf8cf2704725b6f76619399f83.tar glibc-14bc93a967e62abf8cf2704725b6f76619399f83.tar.gz glibc-14bc93a967e62abf8cf2704725b6f76619399f83.tar.bz2 glibc-14bc93a967e62abf8cf2704725b6f76619399f83.zip |
[BZ #14889]
* sunrpc/rpc/svc.h (__svc_accept_failed): New prototype.
* sunrpc/svc.c: Include time.h.
(__svc_accept_failed): New function.
* sunrpc/svc_tcp.c (rendezvous_request): If the accept fails for
any reason other than EINTR, call __svc_accept_failed.
* sunrpc/svc_udp.c (svcudp_recv): Similarly.
* sunrpc/svc_unix.c (rendezvous_request): Similarly.
Diffstat (limited to 'sunrpc/svc.c')
-rw-r--r-- | sunrpc/svc.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/sunrpc/svc.c b/sunrpc/svc.c index 103770a42c..736d4a974c 100644 --- a/sunrpc/svc.c +++ b/sunrpc/svc.c @@ -4,6 +4,23 @@ * There are two sets of procedures here. The xprt routines are * for handling transport handles. The svc routines handle the * list of service routines. + * Copyright (C) 2002-2012 Free Software Foundation, Inc. + * This file is part of the GNU C Library. + * Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. + * + * The GNU C Library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * The GNU C Library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the GNU C Library; if not, see + * <http://www.gnu.org/licenses/>. * * Copyright (c) 2010, Oracle America, Inc. * @@ -41,6 +58,7 @@ #include <rpc/svc.h> #include <rpc/pmap_clnt.h> #include <sys/poll.h> +#include <time.h> #ifdef _RPC_THREAD_SAFE_ #define xports RPC_THREAD_VARIABLE(svc_xports_s) @@ -544,6 +562,21 @@ svc_getreq_common (const int fd) } libc_hidden_nolink_sunrpc (svc_getreq_common, GLIBC_2_2) +/* 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 + request a chance to dequeue and eating an enormous amount of cpu time + in svc_run if we're polling on many file descriptors. */ +void +__svc_accept_failed (void) +{ + if (errno == EMFILE) + { + struct timespec ts = { .tv_sec = 0, .tv_nsec = 50000000 }; + __nanosleep (&ts, NULL); + } +} + #ifdef _RPC_THREAD_SAFE_ void |