I just started another thread about using apache bench. I'm not sure if it is 
working as advertised, and I wonder if it might be misleading us with the 
testing of this potential race condition fix.

Using the most recent version of queue.c, I have been able to create a timeout 
on the apache bench test. That is, the client gets stuck and eventually times 
out and quits. 

The ab command was:

$ ab -t 500 -n 50 -c 1 http://192.168.1.102:8000/bgwrite/sns-thumb.jpg 

There is a rotation of 0-5 sec delay built in to this, so even with a 28k 
file, it takes a while to chew through 50 requests. (about 101 sec). The -t 
500 appears to be a useless option, ab always times out much quicker than 
this value.

Now how to get ab stuck and give up? I use a regular browser (mozilla), and I 
try to load the same image, I hit reload like 5-7 times or so. The number of 
reloads is larger than the number of maxconns per thread. There is only one 
thread working. 

What may be happening is that the keepalive system is expiring the thread all 
by itself (one client with keepalive). Even though there is a queue, maybe 
the sock and therefore the conn are being reused, giving no other requests a 
chance. The last log entry indicates that the thread has processed too many 
conns and is exiting. Then ab freezes. However, if I reload the page one more 
time in the browser, ab starts up again.

I still think all the evidence points to a logical error of deleting a thread 
and then not maintaining at least one thread (and prefer minthreads) if there 
is something in the queue. This isn't a race condition, I don't think, 
because it is easy to repeat this: it happens exactly the same way every 
time. 

This might not be easy to do correctly because killing threads is part of 
shutting down, so a thread might want to die because of a shutdown, not 
because maxconns was reached, or a timeout. 


In driver.c here is the keep-alive section:

/*
 * Process Sock's returned for keep-alive or close.
 */

      while ((sockPtr = closePtr) != NULL) {
          closePtr = sockPtr->nextPtr;
          if (!stop && sockPtr->state == SOCK_READWAIT) {
            sockPtr->connPtr = AllocConn(drvPtr, &now, sockPtr);
            SockWait(sockPtr, &now, drvPtr->keepwait, &waitPtr); /* <--keep*/
          } else if (!drvPtr->closewait || shutdown(sockPtr->sock, 1) != 0) {
            /* Graceful close diabled or shutdown() failed. */
            SockClose(sockPtr);
          } else {
            SockWait(sockPtr, &now, drvPtr->closewait, &waitPtr);
          }
      }

So it looks like a keep-wait socket is immediately put to the head of the line 
looking for more requests from the same client. If you have a web page with 
50+ images, you can easily blow out any reasonable maxconns setting, or if 
someone reloads a less heavy page. 

tom jackson


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]> 
with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: 
field of your email blank.

Reply via email to