Curious behaviour in gen_tcp, an update... Possible bug in erts

Alexis Lê-Quôc alexis@REDACTED
Thu Feb 1 03:48:37 CET 2001


In erts/emulator/drivers/common/inet_drv.c:4026, there is a call to
tcp_recv(desc, n).

/*********************************/
if (tcp_recv(desc, n) == 0) {
    if (timeout == 0)
	async_error_am(INETP(desc), am_timeout);
    else {
	if (timeout != INET_INFINITY)
	    driver_set_timer(desc->inet.port, timeout);
	sock_select(INETP(desc),(FD_READ|FD_CLOSE),1);
}

return ctl_reply(INET_REP_OK, tbuf, 2, rbuf, rsize);
/*********************************/

The problem is that tcp_recv() can return -1 if the buf allocation (line
4518) fails, which happens when I try to read megabytes of data through the
socket, using binaries.

I don't have a patch available, but I suspect that adding a test for
tcp_recv would be a fix, as well as the appropriate error/clean-up handler.
I can provide test cases if requested (erlang and python). Also, I'm
referring to the latest source code R7B-1.

Cheers,

Alexis






More information about the erlang-questions mailing list