pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
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: Thu, 20 May 2010 08:44:26 +0900
Message-ID: <4BF477DA.8000208@tpf.co.jp> (raw)
In-Reply-To: <4BF35CC2.2010801@tpf.co.jp>
References: <c9c581e2e762ff7fbaba414b2bb54d98@niceng.com>
	<4BF32A8E.3030900@tpf.co.jp>
	<4BF35CC2.2010801@tpf.co.jp>

Hiroshi Inoue wrote:
> Hiroshi Inoue wrote:
>> Hi,
>>
>> Could you please try the attached patch?
> 
> Oops it doesn't seem to work.
> Another way is to use poll() instead of select().

OK I made a patch to use poll().
Please #define HAVE_POLL e.g. in config.h and try the attached patch.

regards,
Hiroshi Inoue

Attachments:

socket.diff (text/plain, 3.4K) download diff -c ../psqlodbc/socket.c ./socket.c *** ../psqlodbc/socket.c 2010-01-11 09:56:18.605000000 +0900 --- ./socket.c 2010-05-19 17:03:10.874000000 +0900 *************** *** 350,357 **** --- 350,362 ---- if (connect(self->socket, (struct sockaddr *) &(self->sadr_area), self->sadr_len) < 0) { int ret, optval; + int wait_sec = 0; + #ifdef HAVE_POLL + struct pollfd fds; + #else fd_set fds, except_fds; struct timeval tm; + #endif /* HAVE_POLL */ socklen_t optlen = sizeof(optval); time_t t_now, t_finish = 0; BOOL tm_exp = FALSE; *************** *** 377,391 **** { t_now = time(NULL); t_finish = t_now + timeout; ! tm.tv_sec = timeout; ! tm.tv_usec = 0; } do { FD_ZERO(&fds); 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; --- 382,404 ---- { t_now = time(NULL); t_finish = t_now + timeout; ! wait_sec = timeout; } do { + #ifdef HAVE_POLL + fds.fd = self->socket; + fds.events = POLLOUT; + fds.revents = 0; + ret = poll(&fds, 1, timeout > 0 ? wait_sec * 1000 : -1); + #else + tm.tv_sec = wait_sec; + tm.tv_usec = 0; FD_ZERO(&fds); 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); + #endif /* HAVE_POLL */ gerrno = SOCK_ERRNO; if (0 < ret) break; *************** *** 398,407 **** if (t_now = time(NULL), t_now >= t_finish) tm_exp = TRUE; else ! { ! tm.tv_sec = (long) (t_finish - t_now); ! tm.tv_usec = 0; ! } } } while (!tm_exp); if (tm_exp) --- 411,417 ---- if (t_now = time(NULL), t_now >= t_finish) tm_exp = TRUE; else ! wait_sec = t_finish - t_now; } } while (!tm_exp); if (tm_exp) *************** *** 475,482 **** --- 485,496 ---- static int SOCK_wait_for_ready(SocketClass *sock, BOOL output, int retry_count) { int ret, gerrno; + #ifdef HAVE_POLL + struct pollfd fds; + #else fd_set fds, except_fds; struct timeval tm; + #endif /* HAVE_POLL */ BOOL no_timeout = TRUE; if (0 == retry_count) *************** *** 488,493 **** --- 502,513 ---- no_timeout = TRUE; #endif /* USE_SSL */ do { + #ifdef HAVE_POLL + fds.fd = sock->socket; + fds.events = output ? POLLOUT : POLLIN; + fds.revents = 0; + ret = poll(&fds, 1, no_timeout ? -1 : retry_count * 1000); + #else FD_ZERO(&fds); FD_ZERO(&except_fds); FD_SET(sock->socket, &fds); *************** *** 498,503 **** --- 518,524 ---- tm.tv_usec = 0; } ret = select((int) sock->socket + 1, output ? NULL : &fds, output ? &fds : NULL, &except_fds, no_timeout ? NULL : &tm); + #endif /* HAVE_POLL */ gerrno = SOCK_ERRNO; } while (ret < 0 && EINTR == gerrno); if (retry_count < 0) diff -c ../psqlodbc/socket.h ./socket.h *** ../psqlodbc/socket.h 2010-01-11 09:56:31.371000000 +0900 --- ./socket.h 2010-05-19 13:15:50.157000000 +0900 *************** *** 21,26 **** --- 21,29 ---- #ifndef WIN32 #define WSAAPI + #ifdef HAVE_POLL + #include <poll.h> + #endif /* HAVE_POLL_H */ #include <sys/types.h> #include <sys/socket.h> #include <sys/un.h>

view thread (10+ messages)  latest in thread

Message-ID: <4BF477DA.8000208@tpf.co.jp>
Permalink:  ../4BF477DA.8000208@tpf.co.jp/
Also on:    postgresql.org/message-id/4BF477DA.8000208@tpf.co.jp

 ·  · 

reply

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: <4BF477DA.8000208@tpf.co.jp>
  References: <c9c581e2e762ff7fbaba414b2bb54d98@niceng.com> <4BF32A8E.3030900@tpf.co.jp> <4BF35CC2.2010801@tpf.co.jp> <4BF477DA.8000208@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