Thread: BUG #1008: fe-misc.c has an ifdef for HAVE_POLL, should be HAVE_POLL_H

BUG #1008: fe-misc.c has an ifdef for HAVE_POLL, should be HAVE_POLL_H

From
"PostgreSQL Bugs List"
Date:
The following bug has been logged online:

Bug reference:      1008
Logged by:          Peter Herndon
Email address:      tpherndon@mindspring.com
PostgreSQL version: 7.4
Operating system:   Mac OS X 10.3.1
Description:        fe-misc.c has an ifdef for HAVE_POLL, should be HAVE_POLL_H
Details:

With stock 7.4, configure options --prefix=/usr/local --with-rendezvous --with-openssl --with-includes=/sw/include
--with-libraries=/sw/lib,make failes on src/interfaces/libpq/fe-misc.c, complaining of undefined functions and
constantsin and around line 1011, pqSocketPoll function.  I poked around my config.log and config.status, and my OS,
andfound no trace of poll.h, instead I have select.h.  Yet the function was crashing the compile in lines looking for
poll.h. I looked at the source a bit more and noticed that the #ifdef was looking for HAVE_POLL, and that everything in
configure.*,as well as the top of fe-misc.c, was looking at HAVE_POLL_H.  So I changed line 1011 to HAVE_POLL_H and the
compilesucceeds. 

Re: BUG #1008: fe-misc.c has an ifdef for HAVE_POLL, should be HAVE_POLL_H

From
Tom Lane
Date:
"PostgreSQL Bugs List" <pgsql-bugs@postgresql.org> writes:
> Description:        fe-misc.c has an ifdef for HAVE_POLL, should be HAVE_POLL_H

That's entirely wrong.  The configure code sets up two configuration
symbols: HAVE_POLL_H indicates whether the header <poll.h> exists,
while HAVE_POLL indicates whether the library function poll() is
available.  The code in fe-misc.c is correct (in each place it uses
these symbols).  If HAVE_POLL isn't getting set by configure, then
that's a bug and you should look into the reason why.

FWIW, this code does compile on OS X 10.2.* and 10.3, so if it fails in
10.3.1 then it's because of something Apple changed recently.

            regards, tom lane

Re: BUG #1008: fe-misc.c has an ifdef for HAVE_POLL, should be HAVE_POLL_H

From
Tom Lane
Date:
"Peter Herndon" <tpherndon@mindspring.com> writes:
>> [ <poll.h> is not present in an OS X 10.3 installation ]

> *sheepishly* It looks like it would be the option of, well, installing
> DevTools for 10.3 or not...  From the looks of it, I never installed
> the 10.3 DevTools on the laptop.  The 10.2 tools were installed, but
> nothing more than that.

Ah.  I had eliminated that idea on the thought "he wouldn't have a
compiler if he'd not installed DevTools".  Didn't think about an upgrade
from 10.2 DevTools.  But that does make sense, since libpoll.dylib will
be part of the base 10.3 OS while poll.h would come in DevTools.

> Thanks for putting up with stupidity.  On the bright side, we uncovered
> a corner case.

Right, now we know what the symptom looks like in PG.  Thanks for taking
the time to track it down.

            regards, tom lane