This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH] The recent thread sunrpc change breaks statd (take 2)


On Sun, May 06, 2001 at 08:48:48PM -0700, H . J . Lu wrote:
> Here is a patch.

Actually, I don't see why we need two separate rpc_thread_variables
structures.
Either -lpthread is present in the scope libc is using, then
__libc_internal_tsd_get will be non-NULL and thus on the first call
to __rpc_thread_variables __libc_tsd_get(RPC_VARS) will give NULL
(and that in turn will call the once function and give the default
on the first call) or -lpthread is not present in the scope libc is using,
in which case __libc_tsd_get(RPC_VARS) will always return the default.
The only problematic place is IMHO when calloc fails, but that is
problematic always; having two rpc_thread_variables static structures would
just mean that the first thread for which calloc in __rpc_thread_variables
failed would get unique thread variable set (but second and later threads
would not get unique variable set anyway), having just one means already the
first thread for which calloc fails won't get a unique set, which is not
that big difference.

2001-05-15  Jakub Jelinek  <jakub@redhat.com>

	* sunrpc/rpc_thread.c (rpc_default): Remove.
	(__rpc_thread_destroy): Use __libc_tsd_RPC_VARS_mem instead of
	rpc_default.
	(rpc_thread_multi, __rpc_thread_svc_fdset, __rpc_thread_createerr,
	__rpc_thread_svc_pollfd, __rpc_thread_svc_max_pollfd): Likewise.
	* sunrpc/auth_none.c (authnone_private): Fix a typo.

--- libc/sunrpc/rpc_thread.c.jj	Mon Mar 26 10:02:32 2001
+++ libc/sunrpc/rpc_thread.c	Tue May 15 18:33:25 2001
@@ -9,15 +9,11 @@
 #ifdef _RPC_THREAD_SAFE_
 
 
-/* Variable used in non-threaded applications.  */
+/* Variable used in non-threaded applications or for the first thread.  */
 static struct rpc_thread_variables __libc_tsd_RPC_VARS_mem;
 static struct rpc_thread_variables *__libc_tsd_RPC_VARS_data =
      &__libc_tsd_RPC_VARS_mem;
 
-
-/* This is the variable used for the first thread.  */
-static struct rpc_thread_variables rpc_default;
-
 /*
  * Task-variable destructor
  */
@@ -26,7 +22,7 @@ __rpc_thread_destroy (void)
 {
 	struct rpc_thread_variables *tvp = __rpc_thread_variables();
 
-	if (tvp != NULL && tvp != &rpc_default) {
+	if (tvp != NULL && tvp != &__libc_tsd_RPC_VARS_mem) {
 		__rpc_thread_svc_cleanup ();
 		__rpc_thread_clnt_cleanup ();
 		__rpc_thread_key_cleanup ();
@@ -47,7 +43,7 @@ __rpc_thread_destroy (void)
 static void
 rpc_thread_multi (void)
 {
-  __libc_tsd_set (RPC_VARS, &rpc_default);
+  __libc_tsd_set (RPC_VARS, &__libc_tsd_RPC_VARS_mem);
 }
 
 
@@ -88,7 +84,7 @@ __rpc_thread_svc_fdset (void)
 	struct rpc_thread_variables *tvp;
 
 	tvp = __rpc_thread_variables ();
-	if (tvp == &rpc_default)
+	if (tvp == &__libc_tsd_RPC_VARS_mem)
 		return &svc_fdset;
 	return &tvp->svc_fdset_s;
 }
@@ -99,7 +95,7 @@ __rpc_thread_createerr (void)
 	struct rpc_thread_variables *tvp;
 
 	tvp = __rpc_thread_variables ();
-	if (tvp == &rpc_default)
+	if (tvp == &__libc_tsd_RPC_VARS_mem)
 		return &rpc_createerr;
 	return &tvp->rpc_createerr_s;
 }
@@ -110,7 +106,7 @@ __rpc_thread_svc_pollfd (void)
 	struct rpc_thread_variables *tvp;
 
 	tvp = __rpc_thread_variables ();
-	if (tvp == &rpc_default)
+	if (tvp == &__libc_tsd_RPC_VARS_mem)
 		return &svc_pollfd;
 	return &tvp->svc_pollfd_s;
 }
@@ -121,7 +117,7 @@ __rpc_thread_svc_max_pollfd (void)
 	struct rpc_thread_variables *tvp;
 
 	tvp = __rpc_thread_variables ();
-	if (tvp == &rpc_default)
+	if (tvp == &__libc_tsd_RPC_VARS_mem)
 		return &svc_max_pollfd;
 	return &tvp->svc_max_pollfd_s;
 }
--- libc/sunrpc/auth_none.c.jj	Mon Mar 26 10:02:25 2001
+++ libc/sunrpc/auth_none.c	Tue May 15 18:42:54 2001
@@ -62,7 +62,7 @@ struct authnone_private_s {
   u_int mcnt;
 };
 #ifdef _RPC_THREAD_SAFE_
-#define authnone_private ((struct authnone_private_ *)RPC_THREAD_VARIABLE(authnone_private_s))
+#define authnone_private ((struct authnone_private_s *)RPC_THREAD_VARIABLE(authnone_private_s))
 #else
 static struct authnone_private_s *authnone_private;
 #endif


	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]