From: Zoran V. <zv...@ar...> - 2006-01-07 07:28:43
|
Hi, I have some trouble understanding the code from driver.c below. This is used in both Driver and SpoolerThread code: /* * Attempt to queue any pending connection * after reversing the list to ensure oldest * connections are tried first. */ if (waitPtr != NULL) { sockPtr = NULL; while ((nextPtr = waitPtr) != NULL) { waitPtr = nextPtr->nextPtr; nextPtr->nextPtr = sockPtr; sockPtr = nextPtr; } while (sockPtr != NULL) { nextPtr = sockPtr->nextPtr; /*****/ if (waitPtr != NULL || !NsQueueConn(sockPtr, &now)) { sockPtr->nextPtr = waitPtr; waitPtr = sockPtr; } sockPtr = nextPtr; } } The problem is: if (waitPtr != NULL || !NsQueueConn(sockPtr, &now)) { This means that AFTER the FIRST ready socket which DOES NOT get queued to the connection queue, ALL OTHER ready sockets are also put on the wait list? But why? Those other sockets may need to use some different thread pool which has the free resources to accept the connection? Wouldn't it be better to write: while (sockPtr != NULL) { nextPtr = sockPtr->nextPtr; if (!NsQueueConn(sockPtr, &now)) { sockPtr->nextPtr = waitPtr; waitPtr = sockPtr; } sockPtr = nextPtr; } instead? Zoran |