Re: select()/socket has problems under 2.2.x.

Frederick (niles@axp745.gsfc.nasa.gov)
Fri, 12 Feb 99 17:47:36 -0500


OK here's the problem! The code is (effectively) setting:

int sockbuflen = 0;
setsockopt(sock, SOL_SOCKET, SO_RCVBUF,
(char *)&sockbuflen, sizeof sockbuflen);

This is kind of a user level bug, to set the socket buffer size to
zero. However, the man page for setsockopt says,

"SO_SNDBUF and SO_RCVBUF are options to adjust the
normal buffer sizes allocated for output and input
buffers, respectively. The buffer size may be increased
for high-volume connections, or may be decreased to limit
the possible backlog of incoming data. The system places
an absolute limit on these values."

By doing a getsockopt() I can see this lower limit is currently set to
256. However, for some reason this is too low! For some reason what
ever I set with setsockopt() is multiplied by 2. (another bug?) I did
trial and error and found for:

setsockopt getsockopt select() works?
--------------------------------------------
1008 2016 No
1009 2018 Yes

It other words if I try to set the recieve buffer to 1008 (or less)
with setsockopt() the select() doesn't work, but it does with 1009 (or
above).

I'm running glibc-2.0.7 (rev.29, from redhat-5.2).

Once I set sockbuflen above to a value greater than 1009 everything
started working...

Thanks,
Rick Niles.

>
> This problem was not present in 2.1.132!
>
> I'm sorry to submit a bug report with somewhat limited information on
> this problem, but I wanted to get something out ASAP. I was also
> hoping it was a known problem.... :)
>
> I have a rather large program that has a select() call waiting on
> information from a socket. I have a very small server program that
> servers this information. When I connect to the smaller server with
> telnet or any other small client program it works just fine. However,
> the select() call in the larger program never returns even though the
> send() call came back 100% successful in the small server. I didn't
> write the larger program so it's possiable that it's doing something
> fancier like setting IP socket options.
>
> * This problem occurs with linux-2.2.0 & linux-2.2.1-ac5.
>
> * This problem is NOT present in linux-2.1.132.
>
> * I haven't tired the kernels in between (namely the pre-2.2)
>
> Having un-reliable TCP/IP socket and/or select() stuff seems like "A
> really bad thing". I've double checked that I've upgraded all the
> necessary packages and it seems I have. The fact that it works in
> linux-2.1.132 makes me really think it's a kernel problem.
>
> If this is not a known problem. I will gladly do any debugging,
> including trying every kernel in between to find which one "broke".
>
> Any Ideas?
>
> Thanks,
> Rick Niles.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/