Staticize a couple of functions.

Remove a few unused locks.

Remove locks from application namespace.
This commit is contained in:
deischen 2006-02-27 22:10:59 +00:00
parent 2a2559a103
commit 97af573880
23 changed files with 106 additions and 71 deletions

View File

@ -52,6 +52,7 @@
#undef NIS
#include <rpcsvc/nis.h>
#include "un-namespace.h"
#include "mt_misc.h"
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)auth_des.c 2.2 88/07/29 4.0 RPCSRC; from 1.9 88/02/08 SMI";
@ -481,7 +482,6 @@ static struct auth_ops *
authdes_ops(void)
{
static struct auth_ops ops;
extern mutex_t authdes_ops_lock;
/* VARIABLES PROTECTED BY ops_lock: ops */

View File

@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$");
#include <rpc/xdr.h>
#include <rpc/auth.h>
#include "un-namespace.h"
#include "mt_misc.h"
#define MAX_MARSHAL_SIZE 20
@ -81,7 +82,6 @@ authnone_create()
struct authnone_private *ap = authnone_private;
XDR xdr_stream;
XDR *xdrs;
extern mutex_t authnone_lock;
mutex_lock(&authnone_lock);
if (ap == 0) {
@ -113,7 +113,6 @@ authnone_marshal(AUTH *client, XDR *xdrs)
{
struct authnone_private *ap;
bool_t dummy;
extern mutex_t authnone_lock;
assert(xdrs != NULL);
@ -161,7 +160,6 @@ static struct auth_ops *
authnone_ops()
{
static struct auth_ops ops;
extern mutex_t ops_lock;
/* VARIABLES PROTECTED BY ops_lock: ops */

View File

@ -64,6 +64,7 @@ __FBSDID("$FreeBSD$");
#include <rpc/auth.h>
#include <rpc/auth_unix.h>
#include "un-namespace.h"
#include "mt_misc.h"
/* auth_unix.c */
static void authunix_nextverf (AUTH *);
@ -356,7 +357,6 @@ static struct auth_ops *
authunix_ops()
{
static struct auth_ops ops;
extern mutex_t ops_lock;
/* VARIABLES PROTECTED BY ops_lock: ops */

View File

@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$");
#include <err.h>
#include "un-namespace.h"
#include "rpc_com.h"
#include "mt_misc.h"
#define RPC_MAX_BACKOFF 30 /* seconds */
@ -92,7 +93,6 @@ static void clnt_dg_destroy(CLIENT *);
* at a time.
*/
static int *dg_fd_locks;
extern mutex_t clnt_fd_lock;
static cond_t *dg_cv;
#define release_fd_lock(fd, mask) { \
mutex_lock(&clnt_fd_lock); \
@ -754,7 +754,6 @@ static struct clnt_ops *
clnt_dg_ops()
{
static struct clnt_ops ops;
extern mutex_t ops_lock;
sigset_t mask;
sigset_t newmask;

View File

@ -57,8 +57,7 @@ __FBSDID("$FreeBSD$");
#include <rpc/rpc.h>
#include <rpc/raw.h>
#include "un-namespace.h"
extern mutex_t clntraw_lock;
#include "mt_misc.h"
#define MCALL_MSG_SIZE 24
@ -296,7 +295,6 @@ static struct clnt_ops *
clnt_raw_ops()
{
static struct clnt_ops ops;
extern mutex_t ops_lock;
/* VARIABLES PROTECTED BY ops_lock: ops */

View File

@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$");
#include <fcntl.h>
#include <unistd.h>
#include "un-namespace.h"
#include "mt_misc.h"
#ifndef MAXHOSTNAMELEN
#define MAXHOSTNAMELEN 64
@ -112,7 +113,6 @@ rpc_call(host, prognum, versnum, procnum, inproc, in, outproc, out, nettype)
enum clnt_stat clnt_stat;
struct timeval timeout, tottimeout;
static thread_key_t rpc_call_key;
extern mutex_t tsd_lock;
int main_thread = 1;
if ((main_thread = thr_main())) {

View File

@ -79,6 +79,7 @@ __FBSDID("$FreeBSD$");
#include <rpc/rpc.h>
#include "un-namespace.h"
#include "rpc_com.h"
#include "mt_misc.h"
#define MCALL_MSG_SIZE 24
@ -129,7 +130,6 @@ struct ct_data {
* should be the first thing fixed. One step at a time.
*/
static int *vc_fd_locks;
extern mutex_t clnt_fd_lock;
static cond_t *vc_cv;
#define release_fd_lock(fd, mask) { \
mutex_lock(&clnt_fd_lock); \
@ -753,7 +753,6 @@ static struct clnt_ops *
clnt_vc_ops()
{
static struct clnt_ops ops;
extern mutex_t ops_lock;
sigset_t mask, newmask;
/* VARIABLES PROTECTED BY ops_lock: ops */

View File

@ -63,7 +63,7 @@ int (*__getpublickey_LOCAL)() = 0;
/*
* Get somebody's public key
*/
int
static int
__getpublickey_real(netname, publickey)
char *netname;
char *publickey;

View File

@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$");
#include <sys/wait.h>
#include <sys/fcntl.h>
#include "un-namespace.h"
#include "mt_misc.h"
#define KEY_TIMEOUT 5 /* per-try timeout in seconds */
@ -307,7 +308,6 @@ int vers;
int main_thread;
int fd;
static thread_key_t key_call_key;
extern mutex_t tsd_lock;
#define TOTAL_TIMEOUT 30 /* total timeout talking to keyserver */
#define TOTAL_TRIES 5 /* Number of tries */

View File

@ -11,6 +11,25 @@ __FBSDID("$FreeBSD$");
#include <stdlib.h>
#include <string.h>
#include "un-namespace.h"
#include "mt_misc.h"
/* Take these objects out of the application namespace. */
#define svc_lock __svc_lock
#define svc_fd_lock __svc_fd_lock
#define rpcbaddr_cache_lock __rpcbaddr_cache_lock
#define authdes_ops_lock __authdes_ops_lock
#define authnone_lock __authnone_lock
#define authsvc_lock __authsvc_lock
#define clnt_fd_lock __clnt_fd_lock
#define clntraw_lock __clntraw_lock
#define dupreq_lock __dupreq_lock
#define loopnconf_lock __loopnconf_lock
#define ops_lock __ops_lock
#define proglst_lock __proglst_lock
#define rpcsoc_lock __rpcsoc_lock
#define svcraw_lock __svcraw_lock
#define tsd_lock __tsd_lock
#define xprtlist_lock __xprtlist_lock
/* protects the services list (svc.c) */
pthread_rwlock_t svc_lock = PTHREAD_RWLOCK_INITIALIZER;
@ -21,22 +40,12 @@ pthread_rwlock_t svc_fd_lock = PTHREAD_RWLOCK_INITIALIZER;
/* protects the RPCBIND address cache */
pthread_rwlock_t rpcbaddr_cache_lock = PTHREAD_RWLOCK_INITIALIZER;
/* protects authdes cache (svcauth_des.c) */
pthread_mutex_t authdes_lock = PTHREAD_MUTEX_INITIALIZER;
/* serializes authdes ops initializations */
pthread_mutex_t authdes_ops_lock = PTHREAD_MUTEX_INITIALIZER;
/* protects des stats list */
pthread_mutex_t svcauthdesstats_lock = PTHREAD_MUTEX_INITIALIZER;
#ifdef KERBEROS
/* auth_kerb.c serialization */
pthread_mutex_t authkerb_lock = PTHREAD_MUTEX_INITIALIZER;
/* protects kerb stats list */
pthread_mutex_t svcauthkerbstats_lock = PTHREAD_MUTEX_INITIALIZER;
#endif /* KERBEROS */
/* auth_none.c serialization */
pthread_mutex_t authnone_lock = PTHREAD_MUTEX_INITIALIZER;
@ -49,27 +58,15 @@ pthread_mutex_t clnt_fd_lock = PTHREAD_MUTEX_INITIALIZER;
/* clnt_raw.c serialization */
pthread_mutex_t clntraw_lock = PTHREAD_MUTEX_INITIALIZER;
/* domainname and domain_fd (getdname.c) and default_domain (rpcdname.c) */
pthread_mutex_t dname_lock = PTHREAD_MUTEX_INITIALIZER;
/* dupreq variables (svc_dg.c) */
pthread_mutex_t dupreq_lock = PTHREAD_MUTEX_INITIALIZER;
/* protects first_time and hostname (key_call.c) */
pthread_mutex_t keyserv_lock = PTHREAD_MUTEX_INITIALIZER;
/* serializes rpc_trace() (rpc_trace.c) */
pthread_mutex_t libnsl_trace_lock = PTHREAD_MUTEX_INITIALIZER;
/* loopnconf (rpcb_clnt.c) */
pthread_mutex_t loopnconf_lock = PTHREAD_MUTEX_INITIALIZER;
/* serializes ops initializations */
pthread_mutex_t ops_lock = PTHREAD_MUTEX_INITIALIZER;
/* protects ``port'' static in bindresvport() */
pthread_mutex_t portnum_lock = PTHREAD_MUTEX_INITIALIZER;
/* protects proglst list (svc_simple.c) */
pthread_mutex_t proglst_lock = PTHREAD_MUTEX_INITIALIZER;
@ -85,9 +82,6 @@ pthread_mutex_t tsd_lock = PTHREAD_MUTEX_INITIALIZER;
/* xprtlist (svc_generic.c) */
pthread_mutex_t xprtlist_lock = PTHREAD_MUTEX_INITIALIZER;
/* serializes calls to public key routines */
pthread_mutex_t serialize_pkey = PTHREAD_MUTEX_INITIALIZER;
#undef rpc_createerr
struct rpc_createerr rpc_createerr;

66
lib/libc/rpc/mt_misc.h Normal file
View File

@ -0,0 +1,66 @@
/*
* Copyright (C) 12006 The FreeBSD Project. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef _MT_MISC_H
#define _MT_MISC_H
/* Take these locks out of the application namespace. */
#define svc_lock __svc_lock
#define svc_fd_lock __svc_fd_lock
#define rpcbaddr_cache_lock __rpcbaddr_cache_lock
#define authdes_ops_lock __authdes_ops_lock
#define authnone_lock __authnone_lock
#define authsvc_lock __authsvc_lock
#define clnt_fd_lock __clnt_fd_lock
#define clntraw_lock __clntraw_lock
#define dupreq_lock __dupreq_lock
#define loopnconf_lock __loopnconf_lock
#define ops_lock __ops_lock
#define proglst_lock __proglst_lock
#define rpcsoc_lock __rpcsoc_lock
#define svcraw_lock __svcraw_lock
#define tsd_lock __tsd_lock
#define xprtlist_lock __xprtlist_lock
extern pthread_rwlock_t svc_lock;
extern pthread_rwlock_t svc_fd_lock;
extern pthread_rwlock_t rpcbaddr_cache_lock;
extern pthread_mutex_t authdes_ops_lock;
extern pthread_mutex_t svcauthdesstats_lock;
extern pthread_mutex_t authnone_lock;
extern pthread_mutex_t authsvc_lock;
extern pthread_mutex_t clnt_fd_lock;
extern pthread_mutex_t clntraw_lock;
extern pthread_mutex_t dupreq_lock;
extern pthread_mutex_t loopnconf_lock;
extern pthread_mutex_t ops_lock;
extern pthread_mutex_t proglst_lock;
extern pthread_mutex_t rpcsoc_lock;
extern pthread_mutex_t svcraw_lock;
extern pthread_mutex_t tsd_lock;
extern pthread_mutex_t xprtlist_lock;
#endif

View File

@ -74,8 +74,6 @@ int __rpc_socktype2seman(int);
void *rpc_nullproc(CLIENT *);
int __rpc_sockisbound(int);
struct netbuf *__rpcb_findaddr(rpcprog_t, rpcvers_t, const struct netconfig *,
const char *, CLIENT **);
struct netbuf *__rpcb_findaddr_timed(rpcprog_t, rpcvers_t,
const struct netconfig *, const char *host, CLIENT **clpp,
struct timeval *tp);

View File

@ -63,6 +63,7 @@ __FBSDID("$FreeBSD$");
#include <rpc/nettype.h>
#include "un-namespace.h"
#include "rpc_com.h"
#include "mt_misc.h"
struct handle {
NCONF_HANDLE *nhandle;
@ -236,7 +237,6 @@ __rpc_getconfip(nettype)
struct netconfig *dummy;
int main_thread;
static thread_key_t tcp_key, udp_key;
extern mutex_t tsd_lock;
if ((main_thread = thr_main())) {
netid_udp = netid_udp_main;

View File

@ -74,8 +74,7 @@ __FBSDID("$FreeBSD$");
#include "un-namespace.h"
#include "rpc_com.h"
extern mutex_t rpcsoc_lock;
#include "mt_misc.h"
static CLIENT *clnt_com_create(struct sockaddr_in *, rpcprog_t, rpcvers_t,
int *, u_int, u_int, char *);
@ -399,7 +398,6 @@ clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
void *resultsp; /* pointer to results */
resultproc_t eachresult; /* call with each result obtained */
{
extern mutex_t tsd_lock;
if (thr_main())
clnt_broadcast_result_main = eachresult;

View File

@ -89,6 +89,7 @@ __FBSDID("$FreeBSD$");
#include "un-namespace.h"
#include "rpc_com.h"
#include "mt_misc.h"
static struct timeval tottimeout = { 60, 0 };
static const struct timeval rmttimeout = { 3, 0 };
@ -165,7 +166,6 @@ __rpc_control(request, info)
* block all clnt_create's if we are trying to connect to a host that's down,
* since the lock will be held all during that time.
*/
extern rwlock_t rpcbaddr_cache_lock;
/*
* The routines check_cache(), add_cache(), delete_cache() manage the
@ -448,7 +448,6 @@ local_rpcb()
CLIENT *client;
static struct netconfig *loopnconf;
static char *hostname;
extern mutex_t loopnconf_lock;
int sock;
size_t tsize;
struct netbuf nbuf;
@ -675,7 +674,7 @@ got_entry(relp, nconf)
* Quick check to see if rpcbind is up. Tries to connect over
* local transport.
*/
bool_t
static bool_t
__rpcbind_is_up()
{
struct netconfig *nconf;

View File

@ -62,6 +62,7 @@ __FBSDID("$FreeBSD$");
#include "un-namespace.h"
#include "rpc_com.h"
#include "mt_misc.h"
#define RQCRED_SIZE 400 /* this size is excessive */
@ -84,9 +85,6 @@ static struct svc_callout {
void (*sc_dispatch)(struct svc_req *, SVCXPRT *);
} *svc_head;
extern rwlock_t svc_lock;
extern rwlock_t svc_fd_lock;
static struct svc_callout *svc_find(rpcprog_t, rpcvers_t,
struct svc_callout **, char *);
static void __xprt_do_unregister (SVCXPRT *xprt, bool_t dolock);

View File

@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$");
#include <rpc/rpc.h>
#include <stdlib.h>
#include "un-namespace.h"
#include "mt_misc.h"
/*
* svcauthsw is the bdevsw of server side authentication.
@ -100,7 +101,6 @@ _authenticate(rqst, msg)
int cred_flavor;
struct authsvc *asp;
enum auth_stat dummy;
extern mutex_t authsvc_lock;
/* VARIABLES PROTECTED BY authsvc_lock: asp, Auths */
@ -172,7 +172,6 @@ svc_auth_reg(cred_flavor, handler)
enum auth_stat (*handler)(struct svc_req *, struct rpc_msg *);
{
struct authsvc *asp;
extern mutex_t authsvc_lock;
switch (cred_flavor) {
case AUTH_NULL:

View File

@ -64,6 +64,7 @@ __FBSDID("$FreeBSD$");
#include "un-namespace.h"
#include "rpc_com.h"
#include "mt_misc.h"
#define su_data(xprt) ((struct svc_dg_data *)(xprt->xp_p2))
#define rpc_buffer(xprt) ((xprt)->xp_p1)
@ -306,7 +307,6 @@ svc_dg_ops(xprt)
{
static struct xp_ops ops;
static struct xp_ops2 ops2;
extern mutex_t ops_lock;
/* VARIABLES PROTECTED BY ops_lock: ops */
@ -392,8 +392,6 @@ struct cl_cache {
(xid % (SPARSENESS * ((struct cl_cache *) \
su_data(transp)->su_cache)->uc_size))
extern mutex_t dupreq_lock;
/*
* Enable use of the cache. Returns 1 on success, 0 on failure.
* Note: there is no disable.

View File

@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$");
#include "un-namespace.h"
#include "rpc_com.h"
#include "mt_misc.h"
extern int __svc_vc_setflag(SVCXPRT *, int);
@ -89,7 +90,6 @@ svc_create(dispatch, prognum, versnum, nettype)
SVCXPRT *xprt;
struct netconfig *nconf;
void *handle;
extern mutex_t xprtlist_lock;
/* VARIABLES PROTECTED BY xprtlist_lock: xprtlist */

View File

@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$");
#include <rpc/raw.h>
#include <stdlib.h>
#include "un-namespace.h"
#include "mt_misc.h"
#ifndef UDPMSGSIZE
#define UDPMSGSIZE 8800
@ -70,8 +71,6 @@ static struct svc_raw_private {
char verf_body[MAX_AUTH_BYTES];
} *svc_raw_private;
extern mutex_t svcraw_lock;
static enum xprt_stat svc_raw_stat(SVCXPRT *);
static bool_t svc_raw_recv(SVCXPRT *, struct rpc_msg *);
static bool_t svc_raw_reply(SVCXPRT *, struct rpc_msg *);
@ -239,7 +238,6 @@ svc_raw_ops(xprt)
{
static struct xp_ops ops;
static struct xp_ops2 ops2;
extern mutex_t ops_lock;
/* VARIABLES PROTECTED BY ops_lock: ops */

View File

@ -52,13 +52,13 @@ __FBSDID("$FreeBSD$");
#include <rpc/rpc.h>
#include "rpc_com.h"
#include "mt_misc.h"
void
svc_run()
{
fd_set readfds, cleanfds;
struct timeval timeout;
extern rwlock_t svc_fd_lock;
timeout.tv_sec = 30;
timeout.tv_usec = 0;
@ -92,8 +92,6 @@ svc_run()
void
svc_exit()
{
extern rwlock_t svc_fd_lock;
rwlock_wrlock(&svc_fd_lock);
FD_ZERO(&svc_fdset);
rwlock_unlock(&svc_fd_lock);

View File

@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$");
#include "un-namespace.h"
#include "rpc_com.h"
#include "mt_misc.h"
static void universal(struct svc_req *, SVCXPRT *);
@ -106,8 +107,6 @@ rpc_reg(prognum, versnum, procnum, progname, inproc, outproc, nettype)
struct netconfig *nconf;
int done = FALSE;
void *handle;
extern mutex_t proglst_lock;
if (procnum == NULLPROC) {
@ -250,7 +249,6 @@ universal(rqstp, transp)
char *outdata;
char *xdrbuf;
struct proglst *pl;
extern mutex_t proglst_lock;
/*
* enforce "procnum 0 is echo" convention

View File

@ -68,10 +68,9 @@ __FBSDID("$FreeBSD$");
#include <rpc/rpc.h>
#include "rpc_com.h"
#include "mt_misc.h"
#include "un-namespace.h"
extern rwlock_t svc_fd_lock;
static SVCXPRT *makefd_xprt(int, u_int, u_int);
static bool_t rendezvous_request(SVCXPRT *, struct rpc_msg *);
static enum xprt_stat rendezvous_stat(SVCXPRT *);
@ -672,7 +671,6 @@ svc_vc_ops(xprt)
{
static struct xp_ops ops;
static struct xp_ops2 ops2;
extern mutex_t ops_lock;
/* VARIABLES PROTECTED BY ops_lock: ops, ops2 */
@ -697,7 +695,6 @@ svc_vc_rendezvous_ops(xprt)
{
static struct xp_ops ops;
static struct xp_ops2 ops2;
extern mutex_t ops_lock;
mutex_lock(&ops_lock);
if (ops.xp_recv == NULL) {