Subject Re: Firebird crash at 63 connection
Author Petr Hartman
--- In, André Pietzner <ap@...>
> I cant establish more then 63 connection at the same time.
> On the 64 connection crash the FB.


we had the same problem on several OS (Windows XP, Windows 2003
Server). My colleague who dealt with this problem wrote me:

Function select() does not accept more than 64 socket handles. In
win32.hlp for function select() is written this:
(The default value of FD_SETSIZE is 64, which can be modified by
#defining FD_SETSIZE to another value before #including WINSOCK2.H.)

Anyhow the function uses internally WaitForMultipleObjects, where the
limit is specified differently:
nCount: Specifies the number of object handles in the array pointed
to by lpHandles. The maximum number of object handles is

Actually on any Windows NT 5 system there can not be more than 64
handles in Wait functions.

In kernel-mode, the limit is even more strict. For
KeWaitForMultipleObjects the manual says this:
If either Count > MAXIMUM_WAIT_OBJECTS or ... , the system issues Bug
The "Bug Check" is also known as a "blue-screen".
Anyhow the user-mode call is checked and just returns

So if fbserver specifies more than 64 sockets in select(), it gets
immediatelly WAIT_FAILED with GetLastError probably
ERROR_INVALID_PARAMETER or WSAEINVAL?, in which case it completelly
fails to service all existing sockets.

A temporary solution for this is loading a patch dll, that revectors
system select() function, and passes sockets in groups by 64 to
actual select() function.
We may provide a sample code that handles this...

So can anybody confirm that it is true?

Best regards,
Petr Hartman