2 * Redistribution and use in source and binary forms, with or without
3 * modification, are permitted provided that the following conditions are
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above
9 * copyright notice, this list of conditions and the following
10 * disclaimer in the documentation and/or other materials
11 * provided with the distribution.
12 * * Neither the name of Sun Microsystems, Inc. nor the names of its
13 * contributors may be used to endorse or promote products derived
14 * from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
19 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
20 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
21 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 * This is the rpc server side idle loop
30 * Wait for input, call server program.
39 /* This function can be used as a signal handler to terminate the
53 struct pollfd *my_pollfd = NULL;
54 int last_max_pollfd = 0;
58 int max_pollfd = svc_max_pollfd;
59 if (max_pollfd == 0 && svc_pollfd == NULL)
62 if (last_max_pollfd != max_pollfd)
64 struct pollfd *new_pollfd
65 = realloc (my_pollfd, sizeof (struct pollfd) * max_pollfd);
67 if (new_pollfd == NULL)
69 perror (_("svc_run: - out of memory"));
73 my_pollfd = new_pollfd;
74 last_max_pollfd = max_pollfd;
77 for (i = 0; i < max_pollfd; ++i)
79 my_pollfd[i].fd = svc_pollfd[i].fd;
80 my_pollfd[i].events = svc_pollfd[i].events;
81 my_pollfd[i].revents = 0;
84 switch (i = __poll (my_pollfd, max_pollfd, -1))
89 perror (_("svc_run: - poll failed"));
94 INTUSE(svc_getreq_poll) (my_pollfd, i);