diff --git a/src/rx/rx.c b/src/rx/rx.c index d49afa9af0..92b7d099a3 100644 --- a/src/rx/rx.c +++ b/src/rx/rx.c @@ -1455,8 +1455,8 @@ osi_socket *socketp; if (!QuotaOK(service)) { continue; } - if (!tno || !tcall->queue_item_header.next) { - /* If we're thread 0, then we'll just use + if (tno==rxi_fcfs_thread_num || !tcall->queue_item_header.next ) { + /* If we're the fcfs thread , then we'll just use * this call. If we haven't been able to find an optimal * choice, and we're at the end of the list, then use a * 2d choice if one has been identified. Otherwise... */ @@ -1608,8 +1608,8 @@ rx_GetCall(tno, cur_service, socketp) for (queue_Scan(&rx_incomingCallQueue, tcall, ncall, rx_call)) { service = tcall->conn->service; if (QuotaOK(service)) { - if (!tno || !tcall->queue_item_header.next ) { - /* If we're thread 0, then we'll just use + if (tno==rxi_fcfs_thread_num || !tcall->queue_item_header.next ) { + /* If we're the fcfs thread, then we'll just use * this call. If we haven't been able to find an optimal * choice, and we're at the end of the list, then use a * 2d choice if one has been identified. Otherwise... */ diff --git a/src/rx/rx_globals.h b/src/rx/rx_globals.h index 160e2c25e4..f8d7580212 100644 --- a/src/rx/rx_globals.h +++ b/src/rx/rx_globals.h @@ -373,10 +373,13 @@ EXT int rxi_callAbortDelay INIT(3000); */ #if defined(AFS_PTHREAD_ENV) +EXT int rxi_fcfs_thread_num INIT(0); EXT pthread_key_t rx_thread_id_key; /* keep track of pthread numbers - protected by rx_stats_mutex, except in rx_Init() before mutex exists! */ EXT int rxi_pthread_hinum INIT(0); +#else +#define rxi_fcfs_thread_num (0) #endif #if defined(RX_ENABLE_LOCKS) diff --git a/src/rx/rx_pthread.c b/src/rx/rx_pthread.c index 44f7135bd1..6394f34b53 100644 --- a/src/rx/rx_pthread.c +++ b/src/rx/rx_pthread.c @@ -133,9 +133,6 @@ void rxi_StartServerProc(proc, stacksize) printf("Unable to Create Rx server thread\n"); exit(1); } - MUTEX_ENTER(&rx_stats_mutex); - ++rxi_pthread_hinum; - MUTEX_EXIT(&rx_stats_mutex); AFS_SIGSET_RESTORE(); } @@ -282,7 +279,21 @@ void rx_ServerProc() rxi_dataQuota += rx_initSendWindow; /* Reserve some pkts for hard times */ /* threadID is used for making decisions in GetCall. Get it by bumping * number of threads handling incoming calls */ - threadID = rxi_availProcs++; + /* Unique thread ID: used for scheduling purposes *and* as index into + the host hold table (fileserver). + The previously used rxi_availProcs is unsuitable as it + will already go up and down as packets arrive while the server + threads are still initialising! The recently introduced + rxi_pthread_hinum does not necessarily lead to a server + thread with id 0, which is not allowed to hop through the + incoming call queue. + So either introduce yet another counter or flag the FCFS + thread... chose the latter. + */ + threadID = ++rxi_pthread_hinum; + if (rxi_fcfs_thread_num==0 && rxi_fcfs_thread_num!=threadID) + rxi_fcfs_thread_num=threadID; + ++rxi_availProcs; MUTEX_EXIT(&rx_stats_mutex); while(1) {