[erlang-questions] tcp_send_error

Sverker Eriksson sverker@REDACTED
Wed Apr 8 16:28:12 CEST 2009


Anthony Shipman wrote:
> I am looking at the source for inet_drv.c in 12B4. In the tcp_send_error() 
> function it says
>
> 	 * Note: The following message might get lost, in case the error
> 	 * occurred when we tried to write taken from the queue (no caller).
>
> Can the message really get lost and under what circumstances?
>
>   
When the process is not blocking in prim_inet:send() waiting for a 
reply. That is, the send operation was done asynchronous triggered by an 
internal polled write-event from the socket.

> In the kernel application prim_inet:send() the code waits indefinitely for a 
> response from the driver. If it can get lost then it looks like a send() can 
> block forever. I've got a case where high traffic over a very slow link 
> appears to result in prim_inet:send() getting stuck.
>
>   
Changes have been made to that code in R12B-5, R13A, R13B. Here are two 
fixes in the release notes regarding hanging send's:

R13A:
Calling gen_tcp:send() from several processes on socket with option 
send_timeout
could lead to much longer timeout than specified. The solution is a new 
socket option
{send_timeout_close,true} that will do automatic close on timeout. 
Subsequent calls
to send will then immediately fail due to the closed connection.

Coming R13B:
Fixed a bug on Windows that could make gen_tcp:send hang trying to send 
an iolist
of more than 16 binaries.


/Sverker, Erlang/OTP Ericsson





More information about the erlang-questions mailing list