From 5c797a24a7d6337b5e654079a8d815199b1e8364 Mon Sep 17 00:00:00 2001
From: Carmelo Amoroso <carmelo.amoroso@st.com>
Date: Thu, 2 Feb 2012 18:22:36 +0100
Subject: [PATCH] inet:rpc: fix authnone_marshal in multithreading context
This is a port of glibc's fix by Zack Weinberg as reported
in http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=142312,
and discussed in http://sourceware.org/ml/libc-alpha/2002-04/msg00069.html
Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
libc/inet/rpc/auth_none.c | 59 +++++++++++++++++++++----------------------
libc/inet/rpc/rpc_private.h | 2 --
libc/inet/rpc/rpc_thread.c | 1 -
3 files changed, 29 insertions(+), 33 deletions(-)
diff --git a/libc/inet/rpc/auth_none.c b/libc/inet/rpc/auth_none.c
index c48bbfe..d066f6b 100644
--- a/libc/inet/rpc/auth_none.c
+++ b/libc/inet/rpc/auth_none.c
@@ -66,49 +66,48 @@ struct authnone_private_s {
char marshalled_client[MAX_MARSHAL_SIZE];
-#ifdef __UCLIBC_HAS_THREADS__
-#define authnone_private (*(struct authnone_private_s **)&RPC_THREAD_VARIABLE(authnone_private_s))
-static struct authnone_private_s *authnone_private;
+static struct authnone_private_s authnone_private;
+__libc_once_define(static, authnone_private_guard);
+static void authnone_create_once (void);
+authnone_create_once (void)
struct authnone_private_s *ap;
- ap = (struct authnone_private_s *) authnone_private;
- ap = (struct authnone_private_s *) calloc (1, sizeof (*ap));
- ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth;
- ap->no_client.ah_ops = (struct auth_ops *)&ops;
- xdrmem_create (xdrs, ap->marshalled_client, (u_int) MAX_MARSHAL_SIZE,
- (void) xdr_opaque_auth (xdrs, &ap->no_client.ah_cred);
- (void) xdr_opaque_auth (xdrs, &ap->no_client.ah_verf);
- ap->mcnt = XDR_GETPOS (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 = (struct auth_ops *) &ops;
+ xdrmem_create(xdrs, ap->marshalled_client,
+ (u_int) MAX_MARSHAL_SIZE, XDR_ENCODE);
+ (void) xdr_opaque_auth(xdrs, &ap->no_client.ah_cred);
+ (void) xdr_opaque_auth(xdrs, &ap->no_client.ah_verf);
+ ap->mcnt = XDR_GETPOS (xdrs);
+ __libc_once (authnone_private_guard, authnone_create_once);
+ return &authnone_private.no_client;
libc_hidden_def(authnone_create)
-authnone_marshal (AUTH *client attribute_unused, XDR *xdrs)
+authnone_marshal (AUTH *client, XDR *xdrs)
struct authnone_private_s *ap;