Nonblocking socket read gets lots of EAGAIN

  • Follow


I am writing a web server load test tool, like JMeter, but in UNIX/C, 
using non-blocking socket (fcntl O_NONBLOCK).  My read() gets lots of -1 
return with errno == EAGAIN right after web server restart, but it seems 
to automatically return to normal after about 5 minutes or I if restart 
the load test.

The server side is mixture of fast static pages and intensionally slow 
dynamic pages (like lots of database ops).  I checked that the server 
side is sending data by using another tool with blocking read.

I thought it might have something to do with rcvbuf not filling up, but 
then again, since the read low watermark is only 2 bytes by default, 
then the read should have gotten some data?

Anyone have a solution?  Thank you.
0
Reply mblt 12/3/2005 7:41:18 PM

mblt wrote:
> I am writing a web server load test tool, like JMeter, but in UNIX/C, 
> using non-blocking socket (fcntl O_NONBLOCK).  My read() gets lots of -1 
> return with errno == EAGAIN right after web server restart, but it seems 
> to automatically return to normal after about 5 minutes or I if restart 
> the load test.
I would expect that too, if you read and there is no data - you get
EAGAIN, usually a program can call read() a lot faster than io arrives.
and when something arrives you do a bit processing, and the chance there 
is data the next time too is a bit higher.

Use select or poll to be scheduled when data arrives.
0
Reply ISO 12/5/2005 6:48:01 AM


1 Replies
720 Views

(page loaded in 0.029 seconds)

Similiar Articles:




7/23/2012 7:28:18 PM


Reply: