summaryrefslogtreecommitdiff
path: root/sunrpc/svc_run.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-07-31 13:33:18 +0000
committerJakub Jelinek <jakub@redhat.com>2007-07-31 13:33:18 +0000
commit32c075e1f01849e161724bbd400ba77244e482cc (patch)
tree5f083a3f352104f32bb6c902d57fa3f294bd8d4d /sunrpc/svc_run.c
parentd6220e9ee38c1c9285221b023346201ec5f511b3 (diff)
downloadglibc-32c075e1f01849e161724bbd400ba77244e482cc.tar.gz
.
Diffstat (limited to 'sunrpc/svc_run.c')
-rw-r--r--sunrpc/svc_run.c38
1 files changed, 14 insertions, 24 deletions
diff --git a/sunrpc/svc_run.c b/sunrpc/svc_run.c
index f1f47fbf30..d5e24dd0fc 100644
--- a/sunrpc/svc_run.c
+++ b/sunrpc/svc_run.c
@@ -51,52 +51,42 @@ void
svc_run (void)
{
int i;
- struct pollfd *my_pollfd = NULL;
- int last_max_pollfd = 0;
for (;;)
{
- int max_pollfd = svc_max_pollfd;
- if (max_pollfd == 0 && svc_pollfd == NULL)
- break;
+ struct pollfd *my_pollfd;
- if (last_max_pollfd != max_pollfd)
- {
- struct pollfd *new_pollfd
- = realloc (my_pollfd, sizeof (struct pollfd) * max_pollfd);
-
- if (new_pollfd == NULL)
- {
- perror (_("svc_run: - out of memory"));
- break;
- }
+ if (svc_max_pollfd == 0 && svc_pollfd == NULL)
+ return;
- my_pollfd = new_pollfd;
- last_max_pollfd = max_pollfd;
+ my_pollfd = malloc (sizeof (struct pollfd) * svc_max_pollfd);
+ if (my_pollfd == NULL)
+ {
+ perror (_("svc_run: - out of memory"));
+ return;
}
- for (i = 0; i < max_pollfd; ++i)
+ for (i = 0; i < svc_max_pollfd; ++i)
{
my_pollfd[i].fd = svc_pollfd[i].fd;
my_pollfd[i].events = svc_pollfd[i].events;
my_pollfd[i].revents = 0;
}
- switch (i = __poll (my_pollfd, max_pollfd, -1))
+ switch (i = __poll (my_pollfd, svc_max_pollfd, -1))
{
case -1:
+ free (my_pollfd);
if (errno == EINTR)
continue;
perror (_("svc_run: - poll failed"));
- break;
+ return;
case 0:
+ free (my_pollfd);
continue;
default:
INTUSE(svc_getreq_poll) (my_pollfd, i);
- continue;
+ free (my_pollfd);
}
- break;
}
-
- free (my_pollfd);
}