From cff48dcb5210e38e0048a04fc3151d045bdca4ce Mon Sep 17 00:00:00 2001 From: Rainer Toebbicke Date: Mon, 3 Feb 2003 20:45:51 +0000 Subject: [PATCH] rx-thread-id-assignment-fixes-20030203 in rx_pthread.c the ++rxi_pthread_hinum; has to be protected by the rx_stats_mutex in all three cases. In the file I attached in the openafs-devel article the last one was accidentally unprotected. the FSYNC_sync thread (fssync.c) needs needs to be handled as well. --- src/rx/rx_pthread.c | 2 ++ src/vol/fssync.c | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/rx/rx_pthread.c b/src/rx/rx_pthread.c index 2a73d40..3820d2e 100644 --- a/src/rx/rx_pthread.c +++ b/src/rx/rx_pthread.c @@ -372,7 +372,9 @@ int rxi_Listen(osi_socket sock) printf("Unable to create socket listener thread\n"); exit(1); } + MUTEX_ENTER(&rx_stats_mutex); ++rxi_pthread_hinum; + MUTEX_EXIT(&rx_stats_mutex); AFS_SIGSET_RESTORE(); return 0; } diff --git a/src/vol/fssync.c b/src/vol/fssync.c index 09d0d23..7fabc4d 100644 --- a/src/vol/fssync.c +++ b/src/vol/fssync.c @@ -261,10 +261,23 @@ static void FSYNC_sync() { extern VInit; int code; int numTries; +#ifdef AFS_PTHREAD_ENV + int tid; +#endif #ifndef AFS_NT40_ENV signal(SIGPIPE, SIG_IGN); #endif + +#ifdef AFS_PTHREAD_ENV + /* set our 'thread-id' so that the host hold table works */ + MUTEX_ENTER(&rx_stats_mutex); /* protects rxi_pthread_hinum */ + tid=++rxi_pthread_hinum; + MUTEX_EXIT(&rx_stats_mutex); + pthread_setspecific(rx_thread_id_key, (void *)tid); + Log("Set thread id %d for FSYNC_sync\n", tid); +#endif /* AFS_PTHREAD_ENV */ + while (!VInit) { /* Let somebody else run until level > 0. That doesn't mean that * all volumes have been attached. */ -- 1.9.4