[Vm-dev] Squeak socket problem ... help!

Göran Krampe goran at krampe.se
Fri Oct 10 01:03:35 UTC 2014


Hi!

On 10/10/2014 02:50 AM, Eliot Miranda wrote:
> On Thu, Oct 9, 2014 at 5:09 PM, Göran Krampe <goran at krampe.se
>     Well, it most probably *is* broke - I mean - I haven't read anywhere
>     that our Socket code is limited to 1024 concurrent sockets and that
>     going above that limit causes the Socket code to stop working? :)
>
>
> "Broke" is the wrong word.  You're running into a soft resource limit
> that you can raise.  But you should only raise it if you know the server

No, see below. When I say 1024 I am not referring to the soft limit. I 
am referring to the fact that select() can not handle more than 1024, 
let me quote from the net:

"The limitation comes from the way select() works, most concretely the 
data type used to represent the list of file descriptors, fd_set. Let’s 
take a look at fd_set in /usr/include/sys/select.h

You will see a definition pretty much like:

typedef struct  {
     long int fds_bits[32];
} fd_set;

I removed a bunch of macros to make the code more clear. As you see you 
have a static array of 32 long ints. This is just a bit map, where each 
bit represents a file descriptor number. 32 * sizeof(long int), for 32 
bit platforms is 1024. So, if you do fd_set(&fd, 10), to add file 
descriptor 10 to an fd_set, it will just set to 1 the 10th bit in the 
bit map, what happens then if you do fd_set(&fd, 2000) ?, you guessed 
right, unpredictable. May be some sort of array overflow (fd_set is, at 
least on my system, implemented using the assembly instruction btsl, bit 
test and set)."


>     But it sounds broke to me, nevertheless. ;)
>
> If it is broke it is the OS that is broke.  But not really.  Having a
> soft limit is a great way to find problems (leaks) while providing
> flexibility.  With no limit the system runs until catastrophe, probably

But... I am not sure if you are misunderstanding or not. We did raise 
the limit but then we got the "Bad descriptor file" not the "Too many 
files open". What I mean with "broke" is the fact that select() can not 
handle more than 1024 *regardless* of limits.

So I think we can not go above 1024 if we still use select(). This is 
the bug I am talking about.

regards, Göran


More information about the Vm-dev mailing list