diff --git a/README.WARNINGS b/README.WARNINGS index 9c439aa924..2861fb4a65 100644 --- a/README.WARNINGS +++ b/README.WARNINGS @@ -57,7 +57,6 @@ libadmin/kas/afs_kasAdmin.c: all : Ubik_Call nonsense libadmin/samples/rxstat_query_peer.c : all : util_RPCStatsStateGet types libadmin/samples/rxstat_query_process.c : all : util_RPCStatsStateGet types libadmin/test/client.c : all : util_RPCStatsStateGet types -rx/rx.c : all (pthread) : rxkad_global_stats_init not proto'd rxkad/ticket5.c : all : v5gen.c has set-but-unused variables ubik/ubikclient.c : strict-protos : ubik_Call volser/vol-dump.c : format : afs_sfsize_t diff --git a/src/libafsrpc/Makefile.in b/src/libafsrpc/Makefile.in index bb09400c9b..3b49d0229e 100644 --- a/src/libafsrpc/Makefile.in +++ b/src/libafsrpc/Makefile.in @@ -134,7 +134,6 @@ rx_user.o: ${RX}/rx_user.c rx_pthread.o: ${RX}/rx_pthread.c $(AFS_CCRULE) $(RX)/rx_pthread.c -CFLAGS_rx.o = @CFLAGS_NOERROR@ rx.o: ${RX}/rx.c $(AFS_CCRULE) $(RX)/rx.c diff --git a/src/rx/rx.c b/src/rx/rx.c index 0216480b74..1ddc09ed72 100644 --- a/src/rx/rx.c +++ b/src/rx/rx.c @@ -193,8 +193,6 @@ extern afs_kmutex_t event_handler_mutex; extern afs_kmutex_t listener_mutex; extern afs_kmutex_t rx_if_init_mutex; extern afs_kmutex_t rx_if_mutex; -extern afs_kmutex_t rxkad_client_uid_mutex; -extern afs_kmutex_t rxkad_random_mutex; extern afs_kcondvar_t rx_event_handler_cond; extern afs_kcondvar_t rx_listener_cond; @@ -222,8 +220,6 @@ rxi_InitPthread(void) MUTEX_INIT(&listener_mutex, "listener", MUTEX_DEFAULT, 0); MUTEX_INIT(&rx_if_init_mutex, "if init", MUTEX_DEFAULT, 0); MUTEX_INIT(&rx_if_mutex, "if", MUTEX_DEFAULT, 0); - MUTEX_INIT(&rxkad_client_uid_mutex, "uid", MUTEX_DEFAULT, 0); - MUTEX_INIT(&rxkad_random_mutex, "rxkad random", MUTEX_DEFAULT, 0); MUTEX_INIT(&rx_debug_mutex, "debug", MUTEX_DEFAULT, 0); CV_INIT(&rx_event_handler_cond, "evhand", CV_DEFAULT, 0); @@ -232,8 +228,6 @@ rxi_InitPthread(void) osi_Assert(pthread_key_create(&rx_thread_id_key, NULL) == 0); osi_Assert(pthread_key_create(&rx_ts_info_key, NULL) == 0); - rxkad_global_stats_init(); - MUTEX_INIT(&rx_rpc_stats, "rx_rpc_stats", MUTEX_DEFAULT, 0); MUTEX_INIT(&rx_freePktQ_lock, "rx_freePktQ_lock", MUTEX_DEFAULT, 0); #ifdef RX_ENABLE_LOCKS diff --git a/src/rxkad/rxkad_client.c b/src/rxkad/rxkad_client.c index 1e36c160bd..f8522d1f90 100644 --- a/src/rxkad/rxkad_client.c +++ b/src/rxkad/rxkad_client.c @@ -33,14 +33,13 @@ #endif /* !UKERNEL */ #else /* ! KERNEL */ #include -#ifdef AFS_PTHREAD_ENV -#include "rx/rxkad.h" -#endif /* AFS_PTHREAD_ENV */ #endif /* KERNEL */ + #include #include +#include "rxkad.h" #include "stats.h" #include "private_data.h" #define XPRT_RXKAD_CLIENT @@ -157,6 +156,8 @@ rxkad_NewClientSecurityObject(rxkad_level level, int code; int size, psize; + rxkad_Init(); + size = sizeof(struct rx_securityClass); tsc = rxi_Alloc(size); memset((void *)tsc, 0, size); diff --git a/src/rxkad/rxkad_common.c b/src/rxkad/rxkad_common.c index e4b01d3762..8eed980a4b 100644 --- a/src/rxkad/rxkad_common.c +++ b/src/rxkad/rxkad_common.c @@ -67,6 +67,32 @@ struct rxkad_stats rxkad_stats = { { 0 } }; #endif /* AFS_PTHREAD_ENV */ #ifdef AFS_PTHREAD_ENV +/* Pthread initialisation */ +static pthread_once_t rxkad_once_init = PTHREAD_ONCE_INIT; +extern pthread_mutex_t rxkad_client_uid_mutex; +extern pthread_mutex_t rxkad_random_mutex; + +static void +rxkad_global_stats_init(void) +{ + osi_Assert(pthread_mutex_init(&rxkad_global_stats_lock, (const pthread_mutexattr_t *)0) == 0); + osi_Assert(pthread_key_create(&rxkad_stats_key, NULL) == 0); + memset(&rxkad_global_stats, 0, sizeof(rxkad_global_stats)); +} + +static void +rxkad_InitPthread(void) { + MUTEX_INIT(&rxkad_client_uid_mutex, "uid", MUTEX_DEFAULT, 0); + MUTEX_INIT(&rxkad_random_mutex, "rxkad random", MUTEX_DEFAULT, 0); + + rxkad_global_stats_init(); +} + +void +rxkad_Init(void) { + osi_Assert(pthread_once(&rxkad_once_init, rxkad_InitPthread) == 0); +} + /* rxkad_stats related stuff */ /* @@ -84,12 +110,6 @@ struct rxkad_stats rxkad_stats = { { 0 } }; osi_Assert((head) && ((head)->prev == NULL)); \ } while(0) -void rxkad_global_stats_init(void) { - osi_Assert(pthread_mutex_init(&rxkad_global_stats_lock, (const pthread_mutexattr_t *)0) == 0); - osi_Assert(pthread_key_create(&rxkad_stats_key, NULL) == 0); - memset(&rxkad_global_stats, 0, sizeof(rxkad_global_stats)); -} - rxkad_stats_t * rxkad_thr_stats_init(void) { rxkad_stats_t * rxkad_stats; @@ -163,6 +183,12 @@ int rxkad_stats_agg(rxkad_stats_t * rxkad_stats) { RXKAD_GLOBAL_STATS_UNLOCK; return 0; } +#else +void +rxkad_Init(void) +{ + return; +} #endif /* AFS_PTHREAD_ENV */ /* static prototypes */ diff --git a/src/rxkad/rxkad_prototypes.h b/src/rxkad/rxkad_prototypes.h index 71da356eec..be03608678 100644 --- a/src/rxkad/rxkad_prototypes.h +++ b/src/rxkad/rxkad_prototypes.h @@ -52,6 +52,8 @@ extern int rxkad_GetResponse(struct rx_securityClass *aobj, extern void rxkad_ResetState(void); /* rxkad_common.c */ +extern void rxkad_Init(void); + struct rxkad_endpoint; extern int rxkad_SetupEndpoint(struct rx_connection *aconnp, struct rxkad_endpoint *aendpointp); @@ -80,8 +82,6 @@ extern int rxkad_GetStats(struct rx_securityClass *aobj, extern rxkad_level rxkad_StringToLevel(char *string); extern char *rxkad_LevelToString(rxkad_level level); -extern void rxkad_global_stats_init(void); - /* rxkad_errs.c */ /* rxkad_server.c */ diff --git a/src/rxkad/rxkad_server.c b/src/rxkad/rxkad_server.c index 0b2745a88e..82b1c96965 100644 --- a/src/rxkad/rxkad_server.c +++ b/src/rxkad/rxkad_server.c @@ -137,6 +137,8 @@ rxkad_NewServerSecurityObject(rxkad_level level, void *get_key_rock, struct rxkad_sprivate *tsp; int size; + rxkad_Init(); + if (!get_key) return 0; diff --git a/src/rxkad/stats.h b/src/rxkad/stats.h index 3df9c3e7e0..34ff09f143 100644 --- a/src/rxkad/stats.h +++ b/src/rxkad/stats.h @@ -69,7 +69,6 @@ struct rxkad_global_stats { extern pthread_mutex_t rxkad_global_stats_lock; extern pthread_key_t rxkad_stats_key; -extern void rxkad_global_stats_init(void); extern rxkad_stats_t * rxkad_thr_stats_init(void); extern int rxkad_stats_agg(rxkad_stats_t *); diff --git a/src/shlibafsrpc/Makefile.in b/src/shlibafsrpc/Makefile.in index 9c5cfd0b04..29b9226cfb 100644 --- a/src/shlibafsrpc/Makefile.in +++ b/src/shlibafsrpc/Makefile.in @@ -155,7 +155,6 @@ rx_user.o: ${RX}/rx_user.c rx_pthread.o: ${RX}/rx_pthread.c $(AFS_CCRULE) $(RX)/rx_pthread.c -CFLAGS_rx.o = @CFLAGS_NOERROR@ rx.o: ${RX}/rx.c $(AFS_CCRULE) $(RX)/rx.c