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... */
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... */
*/
#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)
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();
}
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) {