Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 59005632D91 for ; Tue, 18 May 2010 21:02:48 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 89081-09 for ; Wed, 19 May 2010 00:02:40 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sd.tpf.co.jp (sd.tpf.co.jp [210.161.239.34]) by mail.postgresql.org (Postfix) with SMTP id EC25D632D51 for ; Tue, 18 May 2010 21:02:39 -0300 (ADT) Received: (qmail 17615 invoked by uid 512); 19 May 2010 00:02:35 -0000 Received: from unknown (HELO ?127.0.0.1?) (100.0.32.252) by sd2.tpf-fw-c.co.jp with SMTP; 19 May 2010 00:02:35 -0000 Message-ID: <4BF32A8E.3030900@tpf.co.jp> Date: Wed, 19 May 2010 09:02:22 +0900 From: Hiroshi Inoue User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; ja; rv:1.8.1.24) Gecko/20100228 Thunderbird/2.0.0.24 Mnenhy/0.7.6.0 MIME-Version: 1.0 To: Barry Nicholson CC: pgsql-odbc@postgresql.org Subject: Re: FD_SETSIZE with large #s of files/ports in use References: In-Reply-To: Content-Type: multipart/mixed; boundary="------------040403050003070207000607" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.242 tagged_above=-10 required=5 tests=BAYES_00=-1.9, DNS_FROM_RFC_BOGUSMX=1.668, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201005/22 X-Sequence-Number: 10269 This is a multi-part message in MIME format. --------------040403050003070207000607 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi, Could you please try the attached patch? regards, Hiroshi Inoue Barry Nicholson wrote: > An interesting issue came up the other day. We are working with an > application that opens a considerable number of files and tcp/udp ports > (>3000). Unfortunately, that means that the odbc driver fails > sometimes due to a corrupted stack. We eventually figured out what was > causing the corrupted stack. > > The SOCK_wait_for_ready(SocketClass *sock, BOOL output, int retry_count) > function inside socket.c calls select. Unfortunately, the socket file > descriptor number can be quite large at this time. That means that the > fd_set fds variable can misused. The fd_set variable type only allows > 1024 file descriptors to be used by the calling program on many Linux > versions. This can be changed by setting FD_SETSIZE or __FD_SETSIZE to > a larger number. We have ran tests where we were able to change the > __FD_SETSIZE value in > /usr/src/...linuxversion../linux/include/linux/posix_types.h. The fix > worked well. > > Unfortunately, this isn't a good solution because a software update to > another linux version will invalidate our fix. We've tried various > mechanisms to set FD_SETSIZE or __FD_SETSIZE in socket.c but with no > luck. Has anyone else had this problem and came up with a good fix? > Or is there a better solution? > > Barry Nicholson > Niceng.com --------------040403050003070207000607 Content-Type: text/plain; name="socket.diff" Content-Transfer-Encoding: base64 Content-Disposition: inline; filename="socket.diff" KioqIHNvY2tldC5jLm9yaWcJMjAxMC0wMi0wNCAwMDo0MDo1NS42NDMwMDAwMDAgKzA5MDAK LS0tIHNvY2tldC5jCTIwMTAtMDUtMTkgMDg6NTM6NTkuNDI5MDAwMDAwICswOTAwCioqKioq KioqKioqKioqKgoqKiogMzg1LDM5MSAqKioqCiAgCQkJRkRfWkVSTygmZXhjZXB0X2Zkcyk7 CiAgCQkJRkRfU0VUKHNlbGYtPnNvY2tldCwgJmZkcyk7CiAgCQkJRkRfU0VUKHNlbGYtPnNv Y2tldCwgJmV4Y2VwdF9mZHMpOwohIAkJCXJldCA9IHNlbGVjdCgoaW50KSBzZWxmLT5zb2Nr ZXQgKyAxLCBOVUxMLCAmZmRzLCAmZXhjZXB0X2ZkcywgdGltZW91dCA+IDAgPyAmdG0gOiBO VUxMKTsKICAJCQlnZXJybm8gPSBTT0NLX0VSUk5POwogIAkJCWlmICgwIDwgcmV0KQogIAkJ CQlicmVhazsKLS0tIDM4NSwzOTEgLS0tLQogIAkJCUZEX1pFUk8oJmV4Y2VwdF9mZHMpOwog IAkJCUZEX1NFVChzZW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