diff options
author | Ulrich Drepper <drepper@redhat.com> | 2002-04-20 18:57:50 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2002-04-20 18:57:50 +0000 |
commit | cbba1b889900b8a15252d25600631d5e5cf59188 (patch) | |
tree | 76b531abdd9915d309f4b5e977f97183b8dac6ac /sunrpc/auth_none.c | |
parent | f89bd0e52f765a01be8628f54f5ce3d401bc5d0f (diff) | |
download | glibc-cbba1b889900b8a15252d25600631d5e5cf59188.tar.gz glibc-cbba1b889900b8a15252d25600631d5e5cf59188.tar.xz glibc-cbba1b889900b8a15252d25600631d5e5cf59188.zip |
Update.
2002-04-11 Zack Weinberg <zack@codesourcery.com> * include/rpc/rpc.h (struct rpc_thread_variables): Remove authnone_private_s. * sunrpc/auth_none.c: Include bits/libc-lock.h. Delete #ifdef _RPC_THREAD_SAFE_ block. (authnone_private): Make a struct, not a pointer to struct. (authnone_private_guard): New once-control variable. (authnone_create_once): New function, split out of authnone_create. No need to allocate memory. (authnone_create): Just call authnone_create_once via __libc_once, then return &authnone_private->no_client. (authnone_marshal): Access private data via CLIENT argument, not authnone_private pointer. Fix typo (MAX_MARSHEL_SIZE -> MAX_MARSHAL_SIZE). * sunrpc/rpc_thread.c (__rpc_thread_destroy): No need to free authnone_private_s.
Diffstat (limited to 'sunrpc/auth_none.c')
-rw-r--r-- | sunrpc/auth_none.c | 65 |
1 files changed, 33 insertions, 32 deletions
diff --git a/sunrpc/auth_none.c b/sunrpc/auth_none.c index b235ec3b95..4a1b46f274 100644 --- a/sunrpc/auth_none.c +++ b/sunrpc/auth_none.c @@ -36,8 +36,9 @@ */ #include <rpc/rpc.h> +#include <bits/libc-lock.h> -#define MAX_MARSHEL_SIZE 20 +#define MAX_MARSHAL_SIZE 20 /* * Authenticator operations routines @@ -56,54 +57,54 @@ static struct auth_ops ops = { authnone_destroy }; +/* Internal data and routines */ + struct authnone_private_s { AUTH no_client; - char marshalled_client[MAX_MARSHEL_SIZE]; + char marshalled_client[MAX_MARSHAL_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 -AUTH * -authnone_create (void) +static struct authnone_private_s authnone_private; +__libc_once_define(static, authnone_private_guard); + +static void authnone_create_once (void); + +static void +authnone_create_once (void) { struct authnone_private_s *ap; XDR xdr_stream; XDR *xdrs; - ap = (struct authnone_private_s *) authnone_private; - if (ap == NULL) - { - ap = (struct authnone_private_s *) calloc (1, sizeof (*ap)); - if (ap == NULL) - return NULL; - authnone_private = ap; - } - if (!ap->mcnt) - { - ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth; - ap->no_client.ah_ops = &ops; - xdrs = &xdr_stream; - INTUSE(xdrmem_create) (xdrs, ap->marshalled_client, - (u_int) MAX_MARSHEL_SIZE, XDR_ENCODE); - (void) INTUSE(xdr_opaque_auth) (xdrs, &ap->no_client.ah_cred); - (void) INTUSE(xdr_opaque_auth) (xdrs, &ap->no_client.ah_verf); - ap->mcnt = XDR_GETPOS (xdrs); - XDR_DESTROY (xdrs); - } - return (&ap->no_client); + ap = &authnone_private; + + ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth; + ap->no_client.ah_ops = &ops; + xdrs = &xdr_stream; + INTUSE(xdrmem_create) (xdrs, ap->marshalled_client, + (u_int) MAX_MARSHAL_SIZE, XDR_ENCODE); + (void) INTUSE(xdr_opaque_auth) (xdrs, &ap->no_client.ah_cred); + (void) INTUSE(xdr_opaque_auth) (xdrs, &ap->no_client.ah_verf); + ap->mcnt = XDR_GETPOS (xdrs); + XDR_DESTROY (xdrs); +} + +AUTH * +authnone_create (void) +{ + __libc_once (authnone_private_guard, authnone_create_once); + return &authnone_private.no_client; } -/*ARGSUSED */ static bool_t authnone_marshal (AUTH *client, XDR *xdrs) { struct authnone_private_s *ap; - ap = (struct authnone_private_s *) authnone_private; + /* authnone_create returned authnone_private->no_client, which is + the first field of struct authnone_private_s. */ + ap = (struct authnone_private_s *) client; if (ap == NULL) return FALSE; return (*xdrs->x_ops->x_putbytes) (xdrs, ap->marshalled_client, ap->mcnt); |