]> git.ipfire.org Git - thirdparty/glibc.git/blame - sunrpc/svc.c
Update copyright notices with scripts/update-copyrights
[thirdparty/glibc.git] / sunrpc / svc.c
CommitLineData
28f540f4
RM
1/*
2 * svc.c, Server-side remote procedure call interface.
3 *
4 * There are two sets of procedures here. The xprt routines are
5 * for handling transport handles. The svc routines handle the
6 * list of service routines.
d4697bc9 7 * Copyright (C) 2002-2014 Free Software Foundation, Inc.
14bc93a9
JL
8 * This file is part of the GNU C Library.
9 * Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
10 *
11 * The GNU C Library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
15 *
16 * The GNU C Library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with the GNU C Library; if not, see
23 * <http://www.gnu.org/licenses/>.
28f540f4 24 *
a7ab6ec8
UD
25 * Copyright (c) 2010, Oracle America, Inc.
26 *
27 * Redistribution and use in source and binary forms, with or without
28 * modification, are permitted provided that the following conditions are
29 * met:
30 *
31 * * Redistributions of source code must retain the above copyright
32 * notice, this list of conditions and the following disclaimer.
33 * * Redistributions in binary form must reproduce the above
34 * copyright notice, this list of conditions and the following
35 * disclaimer in the documentation and/or other materials
36 * provided with the distribution.
37 * * Neither the name of the "Oracle America, Inc." nor the names of its
38 * contributors may be used to endorse or promote products derived
39 * from this software without specific prior written permission.
40 *
41 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
42 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
43 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
44 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
45 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
46 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
47 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
48 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
49 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
50 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
51 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
52 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28f540f4
RM
53 */
54
e7fd8a39 55#include <errno.h>
bdb04ee8 56#include <unistd.h>
28f540f4 57#include <rpc/rpc.h>
e7fd8a39 58#include <rpc/svc.h>
28f540f4 59#include <rpc/pmap_clnt.h>
bdb04ee8 60#include <sys/poll.h>
14bc93a9 61#include <time.h>
28f540f4 62
f1e4a4a4 63#ifdef _RPC_THREAD_SAFE_
1bc1a2b9 64#define xports RPC_THREAD_VARIABLE(svc_xports_s)
f1e4a4a4 65#else
28f540f4 66static SVCXPRT **xports;
f1e4a4a4 67#endif
28f540f4
RM
68
69#define NULL_SVC ((struct svc_callout *)0)
e7fd8a39 70#define RQCRED_SIZE 400 /* this size is excessive */
28f540f4 71
bdb04ee8
UD
72/* The services list
73 Each entry represents a set of procedures (an rpc program).
74 The dispatch routine takes request structs and runs the
75 appropriate procedure. */
f1e4a4a4 76struct svc_callout {
bdb04ee8
UD
77 struct svc_callout *sc_next;
78 rpcprog_t sc_prog;
79 rpcvers_t sc_vers;
80 void (*sc_dispatch) (struct svc_req *, SVCXPRT *);
71894681 81 bool_t sc_mapped;
f1e4a4a4
UD
82};
83#ifdef _RPC_THREAD_SAFE_
1bc1a2b9 84#define svc_head RPC_THREAD_VARIABLE(svc_head_s)
f1e4a4a4
UD
85#else
86static struct svc_callout *svc_head;
87#endif
28f540f4
RM
88
89/* *************** SVCXPRT related stuff **************** */
90
bdb04ee8 91/* Activate a transport handle. */
28f540f4 92void
e7fd8a39 93xprt_register (SVCXPRT *xprt)
28f540f4 94{
e7fd8a39 95 register int sock = xprt->xp_sock;
bdb04ee8 96 register int i;
28f540f4 97
e7fd8a39
UD
98 if (xports == NULL)
99 {
bdb04ee8
UD
100 xports = (SVCXPRT **) malloc (_rpc_dtablesize () * sizeof (SVCXPRT *));
101