2 * Copyright (C) 1984 Sun Microsystems, Inc.
3 * Modified by Jeffrey A. Uphoff, 1995, 1997-1999.
4 * Modified by Olaf Kirch, 1996.
10 * Copyright (c) 2009, Sun Microsystems, Inc.
11 * All rights reserved.
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions are met:
15 * - Redistributions of source code must retain the above copyright notice,
16 * this list of conditions and the following disclaimer.
17 * - Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 * - Neither the name of Sun Microsystems, Inc. nor the names of its
21 * contributors may be used to endorse or promote products derived
22 * from this software without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
38 * This has been modified for my own evil purposes to prevent deadlocks
39 * when two hosts start NSM's simultaneously and try to notify each
40 * other (which mainly occurs during testing), or to stop and smell the
41 * roses when I have callbacks due.
46 * This is the RPC server side idle loop.
47 * Wait for input, call server program.
59 static int svc_stop = 0;
62 * This is the global notify list onto which all SM_NOTIFY and CALLBACK
65 notify_list * notify = NULL;
78 * The heart of the server. A crib from libc for the most part...
93 /* Ah, there are some notifications to be processed */
94 while (notify && NL_WHEN(notify) <= time(&now)) {
95 process_notify_list();
102 tv.tv_sec = NL_WHEN(notify) - now;
104 xlog(D_GENERAL, "Waiting for reply... (timeo %d)",
106 selret = select(FD_SETSIZE, &readfds,
107 (void *) 0, (void *) 0, &tv);
109 xlog(D_GENERAL, "Waiting for client connections");
110 selret = select(FD_SETSIZE, &readfds,
111 (void *) 0, (void *) 0, (struct timeval *) 0);
116 if (errno == EINTR || errno == ECONNREFUSED
117 || errno == ENETUNREACH || errno == EHOSTUNREACH)
119 xlog(L_ERROR, "my_svc_run() - select: %m");
123 /* A notify/callback timed out. */
127 selret -= process_reply(&readfds);
129 svc_getreqset(&readfds);