--- sunrpc/auth_none.c 2002/02/14 17:17:26 1.1 +++ sunrpc/auth_none.c 2002/02/14 17:28:46 @@ -36,6 +36,7 @@ */ #include +#include #define MAX_MARSHEL_SIZE 20 @@ -61,25 +62,27 @@ char marshalled_client[MAX_MARSHEL_SIZE]; u_int mcnt; }; -#ifdef _RPC_THREAD_SAFE_ -#define authnone_private ((struct authnone_private_s *)RPC_THREAD_VARIABLE(authnone_private_s)) -#else + static struct authnone_private_s *authnone_private; -#endif +__libc_lock_define_initialized (static, authnone_lock) AUTH * authnone_create (void) { struct authnone_private_s *ap; + AUTH *a; XDR xdr_stream; XDR *xdrs; + __libc_lock_lock (authnone_lock); ap = (struct authnone_private_s *) authnone_private; if (ap == NULL) { ap = (struct authnone_private_s *) calloc (1, sizeof (*ap)); - if (ap == NULL) + if (ap == NULL) { + __libc_lock_unlock (authnone_lock); return NULL; + } authnone_private = ap; } if (!ap->mcnt) @@ -94,7 +97,9 @@ ap->mcnt = XDR_GETPOS (xdrs); XDR_DESTROY (xdrs); } - return (&ap->no_client); + a = &ap->no_client; + __libc_lock_unlock (authnone_lock); + return a; } /*ARGSUSED */ @@ -102,11 +107,16 @@ authnone_marshal (AUTH *client, XDR *xdrs) { struct authnone_private_s *ap; + bool_t ret; + __libc_lock_lock (authnone_lock); ap = (struct authnone_private_s *) authnone_private; if (ap == NULL) - return FALSE; - return (*xdrs->x_ops->x_putbytes) (xdrs, ap->marshalled_client, ap->mcnt); + ret = FALSE; + else + ret = (*xdrs->x_ops->x_putbytes) (xdrs, ap->marshalled_client, ap->mcnt); + __libc_lock_unlock (authnone_lock); + return ret; } static void