This is the mail archive of the cygwin mailing list for the Cygwin project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Hi Erik, why didn't you send this to cygwin-patches? Not much of a problem, just wondering... On Nov 3 15:39, Erik Bray wrote: > [...] > After some playing around I found that I could make up to exactly 1365 > sockets and use them without error. At 1366 I get the error. A very > strange and arbitrary number. It turns out this is limited in Cygwin > by the array in fhandler_socket.cc: > > 496 /* Maximum number of concurrently opened sockets from all Cygwin processes > 497 per session. Note that shared sockets (through dup/fork/exec) are > 498 counted as one socket. */ > 499 #define NUM_SOCKS (32768 / sizeof (wsa_event)) > ... > 510 static wsa_event wsa_events[NUM_SOCKS] __attribute__((section > (".cygwin_dll _common"), shared)); > > This choice for NUM_SOCKS is still seemingly small and pretty > arbitrary, but at least it's a choice, and probably well-motivated. This obviously dates back to pre-64 bit times. The idea at the time was that the .cygwin_dll_common section fits into a single 64K allocation chunk. Every section takes at least this 64K chunk, so we get away with only one of them for this section. Turns out, shared sections have a few issues so we even reduced the usage and only kept stuff in which doesn't pose much of a problem. Right now .cygwin_dll_common has a size of 0x8220 / 0x8200 of a max. of 0x10000, so we have still lots of room and nothing really in need of using a shared section. > However, I think it's a problem that it's defined in terms of > sizeof(wsa_event). On 32-bit Cygwin this is 16, so NUM_SOCKS is 2048 > (a less strange number), whereas on 64-bit Cygwin sizeof(wsa_event) == > 24 (due to sizeof(long) == 8, plus alignment), so we are limited > to...1365 sockets. > > If we have to set a limit I would just hard-code it to 2048 exactly. > I understand that the overhead associated with sockets in Cygwin > probably limits us from having 10s of thousands (much less millions) > and that's OK--I'm not trying to run some kind of C10K challenge on > Cygwin :) We only need another 0x220 bytes so we have a theoretical 0xfde0 / 64992 bytes or 2708 sockets for wsa_events on 64 bit. So, yeah, I think you're right, 2048 is good number. As I wrote in the comment preceeding NUM_SOCKS, these are 2048 independent sockets per user session in parallel. Sockets created by dup or shared via fork/exec only take one slot anyway. 2048 independent sockets per user session should really suffice outside of testcases. > The other problem, then, seems to be a bug in > fhandler_socket::init_events(). It doesn't check the return value of > search_wsa_event_slot(), which returns NULL if the wsa_events array is > full (and the socket is not a shared socket). There's not a great > choice here for error code, but setting ENOBUF seems like the best > option. Yep, bug. Thanks for catching. > Please see attached patch. Can you please send it to cygwin-patches with a bit of additional comment (just a couple of words) why we choose 2048 here? Thanks, Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat
Attachment:
signature.asc
Description: PGP signature
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |