From 44485fed5e427e85e5b0c28070f79a2299963e5a Mon Sep 17 00:00:00 2001 From: Hartmut Reuter Date: Mon, 12 Feb 2001 19:24:48 +0000 Subject: [PATCH] allow-rx-shutdown-for-userlevel-20010212 Allow rx shutdown (state reset) for userlevel rx code, for MR-AFS salvager --- src/rx/rx.c | 35 +++++++++++++++++++++++++++++++++++ src/rx/rx_clock.c | 14 +++++++++++--- src/rx/rx_clock_nt.c | 10 ++++++++++ 3 files changed, 56 insertions(+), 3 deletions(-) diff --git a/src/rx/rx.c b/src/rx/rx.c index 2db8ba8a1..f8ef0f0a7 100644 --- a/src/rx/rx.c +++ b/src/rx/rx.c @@ -91,6 +91,10 @@ extern afs_int32 afs_termState; # include #endif /* KERNEL */ +#ifdef RXDEBUG +extern afs_uint32 LWP_ThreadId(); +#endif /* RXDEBUG */ + #ifdef AFS_GLOBAL_RXLOCK_KERNEL struct rx_tq_debug { afs_int32 rxi_start_aborted; /* rxi_start awoke after rxi_Send in error. */ @@ -6256,6 +6260,8 @@ void shutdown_rx(void) { struct rx_serverQueueEntry *np; register int i, j; + register struct rx_call *call; + register struct rx_serverQueueEntry *sq; LOCK_RX_INIT if (rxinit_status == 1) { @@ -6263,6 +6269,35 @@ void shutdown_rx(void) return; /* Already shutdown. */ } +#ifndef KERNEL + rx_port = 0; +#ifndef AFS_PTHREAD_ENV + FD_ZERO(&rx_selectMask); +#endif /* AFS_PTHREAD_ENV */ + rxi_dataQuota = RX_MAX_QUOTA; +#ifndef AFS_PTHREAD_ENV + rxi_StopListener(); +#endif /* AFS_PTHREAD_ENV */ + shutdown_rxevent(); + rx_SetEpoch(0); +#ifndef AFS_PTHREAD_ENV +#ifndef AFS_USE_GETTIMEOFDAY + clock_UnInit(); +#endif /* AFS_USE_GETTIMEOFDAY */ +#endif /* AFS_PTHREAD_ENV */ + + while (!queue_IsEmpty(&rx_freeCallQueue)) { + call = queue_First(&rx_freeCallQueue, rx_call); + queue_Remove(call); + rxi_Free(call, sizeof(struct rx_call)); + } + + while (!queue_IsEmpty(&rx_idleServerQueue)) { + sq = queue_First(&rx_idleServerQueue, rx_serverQueueEntry); + queue_Remove(sq); + } +#endif /* KERNEL */ + { struct rx_peer **peer_ptr, **peer_end; for (peer_ptr = &rx_peerHashTable[0], diff --git a/src/rx/rx_clock.c b/src/rx/rx_clock.c index 4938035a6..546ae0f66 100644 --- a/src/rx/rx_clock.c +++ b/src/rx/rx_clock.c @@ -46,13 +46,13 @@ struct clock clock_now; /* The last elapsed time ready by clock_GetTimer */ int clock_haveCurrentTime; int clock_nUpdates; /* The actual number of clock updates */ +static int clockInitialized = 0; /* Initialize the clock */ void clock_Init(void) { - static initialized = 0; struct itimerval itimer, otimer; - if (!initialized) { + if (!clockInitialized) { itimer.it_value.tv_sec = STARTVALUE; itimer.it_value.tv_usec = 0; itimer.it_interval.tv_sec = 0; @@ -64,12 +64,20 @@ void clock_Init(void) { fflush (stderr); exit(1); } - initialized = 1; + clockInitialized = 1; } clock_UpdateTime(); } +#ifndef KERNEL +/* Make clock uninitialized. */ +clock_UnInit() +{ + clockInitialized = 0; +} +#endif + /* Compute the current time. The timer gets the current total elapsed time since startup, expressed in seconds and microseconds. This call is almost 200 usec on an APC RT */ void clock_UpdateTime() { diff --git a/src/rx/rx_clock_nt.c b/src/rx/rx_clock_nt.c index 5b1bb934b..d765720a3 100644 --- a/src/rx/rx_clock_nt.c +++ b/src/rx/rx_clock_nt.c @@ -27,6 +27,7 @@ struct clock clock_now; /* The last elapsed time ready by clock_GetTimer */ int clock_haveCurrentTime; int clock_nUpdates; /* The actual number of clock updates */ +static int clockInitialized = 0; /* Timing tests show that we can compute times at about 4uS per call. */ LARGE_INTEGER rxi_clock0; @@ -38,11 +39,20 @@ void clock_Init() exit(1); } + clockInitialized = 1; (void) QueryPerformanceCounter(&rxi_clock0); clock_UpdateTime(); } +#ifndef KERNEL +/* Make clock uninitialized. */ +clock_UnInit() +{ + clockInitialized = 0; +} +#endif + void clock_UpdateTime(void) { LARGE_INTEGER now, delta; -- 2.39.5