From: Hiroshi Inoue <inoue@tpf.co.jp>
To: Barry Nicholson <b.nicholson@niceng.com>
Cc: pgsql-odbc@postgresql.org
Subject: Re: FD_SETSIZE with large #s of files/ports in use
Date: Wed, 19 May 2010 09:02:22 +0900
Message-ID: <4BF32A8E.3030900@tpf.co.jp> (raw)
In-Reply-To: <c9c581e2e762ff7fbaba414b2bb54d98@niceng.com>
References: <c9c581e2e762ff7fbaba414b2bb54d98@niceng.com>
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
Attachments:socket.diff (text/plain, 1.2K) download
*** socket.c.orig 2010-02-04 00:40:55.643000000 +0900
--- socket.c 2010-05-19 08:53:59.429000000 +0900
***************
*** 385,391 ****
FD_ZERO(&except_fds);
FD_SET(self->socket, &fds);
FD_SET(self->socket, &except_fds);
! ret = select((int) self->socket + 1, NULL, &fds, &except_fds, timeout > 0 ? &tm : NULL);
gerrno = SOCK_ERRNO;
if (0 < ret)
break;
--- 385,391 ----
FD_ZERO(&except_fds);
FD_SET(self->socket, &fds);
FD_SET(self->socket, &except_fds);
! ret = select(1, NULL, &fds, &except_fds, timeout > 0 ? &tm : NULL);
gerrno = SOCK_ERRNO;
if (0 < ret)
break;
***************
*** 497,503 ****
tm.tv_sec = retry_count;
tm.tv_usec = 0;
}
! ret = select((int) sock->socket + 1, output ? NULL : &fds, output ? &fds : NULL, &except_fds, no_timeout ? NULL : &tm);
gerrno = SOCK_ERRNO;
} while (ret < 0 && EINTR == gerrno);
if (retry_count < 0)
--- 497,503 ----
tm.tv_sec = retry_count;
tm.tv_usec = 0;
}
! ret = select(1, output ? NULL : &fds, output ? &fds : NULL, &except_fds, no_timeout ? NULL : &tm);
gerrno = SOCK_ERRNO;
} while (ret < 0 && EINTR == gerrno);
if (retry_count < 0)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-odbc@postgresql.org
Cc: inoue@tpf.co.jp, b.nicholson@niceng.com
Subject: Re: FD_SETSIZE with large #s of files/ports in use
In-Reply-To: <4BF32A8E.3030900@tpf.co.jp>
References: <c9c581e2e762ff7fbaba414b2bb54d98@niceng.com> <4BF32A8E.3030900@tpf.co.jp>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox