GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: lib/libc/rpc/svc_run.c Lines: 0 14 0.0 %
Date: 2017-11-07 Branches: 0 9 0.0 %

Line Branch Exec Source
1
/*	$OpenBSD: svc_run.c,v 1.25 2015/09/01 17:31:39 deraadt Exp $ */
2
3
/*
4
 * Copyright (c) 2010, Oracle America, Inc.
5
 *
6
 * Redistribution and use in source and binary forms, with or without
7
 * modification, are permitted provided that the following conditions are
8
 * met:
9
 *
10
 *     * Redistributions of source code must retain the above copyright
11
 *       notice, this list of conditions and the following disclaimer.
12
 *     * Redistributions in binary form must reproduce the above
13
 *       copyright notice, this list of conditions and the following
14
 *       disclaimer in the documentation and/or other materials
15
 *       provided with the distribution.
16
 *     * Neither the name of the "Oracle America, Inc." nor the names of its
17
 *       contributors may be used to endorse or promote products derived
18
 *       from this software without specific prior written permission.
19
 *
20
 *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
 *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
 *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23
 *   FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24
 *   COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
25
 *   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26
 *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
27
 *   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
 *   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29
 *   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30
 *   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
 *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
 */
33
34
/*
35
 * This is the rpc server side idle loop
36
 * Wait for input, call server program.
37
 */
38
#include <rpc/rpc.h>
39
#include <errno.h>
40
#include <unistd.h>
41
#include <stdio.h>
42
#include <stdlib.h>
43
#include <string.h>
44
45
void
46
svc_run(void)
47
{
48
	struct pollfd *pfd = NULL, *newp;
49
	int nready, saved_max_pollfd = 0;
50
51
	for (;;) {
52
		if (svc_max_pollfd > saved_max_pollfd) {
53
			newp = reallocarray(pfd, svc_max_pollfd, sizeof(*pfd));
54
			if (newp == NULL) {
55
				free(pfd);
56
				return;			/* XXX */
57
			}
58
			saved_max_pollfd = svc_max_pollfd;
59
			pfd = newp;
60
		}
61
		memcpy(pfd, svc_pollfd, sizeof(*pfd) * svc_max_pollfd);
62
63
		nready = poll(pfd, svc_max_pollfd, INFTIM);
64
		switch (nready) {
65
		case -1:
66
			if (errno == EINTR)
67
				continue;
68
			free(pfd);
69
			return;					/* XXX */
70
		case 0:
71
			/* should not happen */
72
			continue;
73
		default:
74
			svc_getreq_poll(pfd, nready);
75
		}
76
	}
77
}