occasional ECONNREFUSED when connect()ing.
myself at rojer.pp.ru
Fri Feb 18 06:43:27 PST 2005
guys, there is _source_ of the server at the end of my post!
there are no threads nor forks and backlog is set to 511 (Apache's
and client always waits for rrequst to complete before sending a new one.
Peter Edwards wrote:
>On Fri, 18 Feb 2005 16:18:41 +0300, Deomid Ryabkov <myself at rojer.pp.ru> wrote:
>>I have a strange case of occasional refused connect()'s.
>>The system is running 4.10-STABLE.
>>This was originally reported by one of our developers.
>>The test script he provided is a simple Perl script that repeatedly
>>fetches an URL
>>from Apache running on this same server.
>>In the run of 2000 iterations, there are 5-10 random errors fetching the
>>After further investigation and digging, I uncovered the true cause of
>>connect() returning ECONNREFUSED.
>>To see if this was somehow related to Apache, I wrote my own simple
>>accept()'s a connection, read()'s what supposed to be request and
>>write()'s a stereotypic reply,
>>thus resembling an HTTP request/reply conversation.
>>The number of sporadically occuring connect() errors has increased somewhat,
>>maybe due to quicker turnaround of my stub-server.
>>The question is - why do connections get refused at all?
>>I can think of no valid reasons...
>In your stub server, what do you set the backlog to in the call to listen(2)?
>By the time you get the file descriptor for the new call from
>accept(), the kernel has already established the TCP/IP connection,
>and is maintaining state (ie, using resources) for it
>If you take a while dealing with this new call, (starting a thread,
>forking, or even processing the connection), then by the time you
>invoke accept() again, any number of clients may have attempted to
>connect to you, and the kernel needs to maintain state for every
>connection that has been requested.
>The backlog on the listen call indicates how many of these connections
>the kernel should hold on to: If the number of unaccept()ed
>connections reaches the backlog, you'll start to get ECONREFUSED
>errors at the client. If your stub server is single-threaded, this'll
>be pretty much guaranteed to happen if the number of clients exceeds
>the backlog on ths server's listening socket.
Deomid Ryabkov aka Rojer
myself at rojer.pp.ru
rojer at sysadmins.ru
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 3228 bytes
Desc: S/MIME Cryptographic Signature
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20050218/caf9b90b/smime.bin
More information about the freebsd-hackers