It means if cannot queue socket, does not make sense to queue others because the only fail may happen in NsQueueConn is queue overflow, so need to wait until there are available slots.

Zoran Vasiljevic wrote:
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



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
naviserver-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


--
Vlad Seryakov
571 262-8608 office
[EMAIL PROTECTED]
http://www.crystalballinc.com/vlad/

Reply via email to