freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: Frediano Ziglio <freddy77 AT gmail.com>
- To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
- Subject: Re: [freetds] always poll, even without poll(2)
- Date: Mon, 29 Dec 2008 18:13:01 +0100
Il giorno lun, 22/12/2008 alle 23.16 -0500, James K. Lowden ha scritto:
> Frediano Ziglio wrote:
> >
> > Mmmm... I would put fakepoll.h in include/replacements directory. Also
> > there is similar function named tds_REPLACED so perhaps it would be
> > better to call this function tds_poll for coherence. Also for
> > coherence in include/replacements.h I used defines like
> >
> > #define poll(a,b,c) tds_poll(a,b,c)
> >
> > if poll is not defined. You could include
> > include/replacements/fakepoll.h in include/replacements.h or just
> > include <replacements/fakepoll.h> when used.
>
> Will do.
>
> I think this is wrong, though:
>
> > Sat Dec 20 20:11:46 CET 2008
> > * src/replacements/fakepoll.c:
> > fix win32 portability issue
>
> http://msdn.microsoft.com/en-us/library/ms740141(VS.85).aspx
>
> Microsoft says they *ignore* nfds (parameter 1 of select(2)). So it's OK
> to pass any value to Win32's select() function.
>
> More important, we should check against FD_SETSIZE even on Win32:
>
> "The variable FD_SETSIZE determines the maximum number of descriptors
> in
> a set. (The default value of FD_SETSIZE is 64, which can be modified by
> defining FD_SETSIZE to another value before including Winsock2.h.)"
>
> but the count, not the maxfd, is what matters.
>
> I updated fakepoll.c according to that theory. I left in the maxfd
> computation because preprocessor directives make code hard to read and
> understand. The fewer we have, the better, even if it means a few extra
> cycles.
>
I saw the commit
What do you think about
@@ -72,37 +72,38 @@
/*
* Transcribe flags from the poll set to the fd sets.
* Also ensure we don't exceed select's capabilities.
*/
for (p = fds; p < endp; p++) {
/* Negative fd checks nothing and always reports zero */
if (p->fd < 0) {
continue;
}
+#if defined(WIN32)
+ /* Win32 cares about the number of descriptors, not the
highest one. */
+ ++maxfd;
+#else
if (p->fd > maxfd)
maxfd = p->fd;
+#endif
/* POLLERR is never set coming in; poll(2) always reports
errors */
/* But don't report if we're not listening to anything at
all. */
if (p->events & POLLIN)
FD_SET(p->fd, &fdsr);
if (p->events & POLLOUT)
FD_SET(p->fd, &fdsw);
if (p->events != 0)
FD_SET(p->fd, &fdsp);
}
-#if defined(WIN32)
- /* Win32 cares about the number of descriptors, not the highest one.
*/
- maxfd = nfds;
-#endif
/*
* If any FD is too big for select(2), we need to return an error.
* Which one, though, is debatable. There's no defined errno for
* this for poll(2) because it's an "impossible" condition;
* there's no such thing as "too many" FD's to check.
* select(2) returns EINVAL, and so do we.
* EFAULT might be better.
*/
if (maxfd > FD_SETSIZE) {
assert(FD_SETSIZE > 0);
Frediano
-
[freetds] always poll, even without poll(2),
James K. Lowden, 12/20/2008
-
Re: [freetds] always poll, even without poll(2),
Frediano Ziglio, 12/20/2008
-
Re: [freetds] always poll, even without poll(2),
James K. Lowden, 12/22/2008
- Re: [freetds] always poll, even without poll(2), Frediano Ziglio, 12/23/2008
-
Re: [freetds] always poll, even without poll(2),
Frediano Ziglio, 12/29/2008
- Re: [freetds] always poll, even without poll(2), James K. Lowden, 12/30/2008
-
Re: [freetds] always poll, even without poll(2),
James K. Lowden, 12/22/2008
-
Re: [freetds] always poll, even without poll(2),
Frediano Ziglio, 12/20/2008
Archive powered by MHonArc 2.6.24.