From: Noah Misch <noah@leadboat.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Shiv Shivaraju Gowda (shivshi) <shivshi@cisco.com>
Cc: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
Cc: alvherre@2ndquadrant.com
Subject: Re: Re: PostgreSQL 6.2.5 Visual Studio Build does not pass the regression tests.
Date: Fri, 24 Jan 2014 16:36:56 -0500
Message-ID: <20140124213656.GB2001840@tornado.leadboat.com> (raw)
In-Reply-To: <12094.1390576464@sss.pgh.pa.us>
References: <CEB3FA9D.6450%shivshi@cisco.com>
<20140124042742.GA1975540@tornado.leadboat.com>
<12094.1390576464@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
On Fri, Jan 24, 2014 at 10:14:24AM -0500, Tom Lane wrote:
> Noah Misch <noah@leadboat.com> writes:
> > Would you verify that the attached patch fixes your builds?
>
> The aspect of this patch that leaves ImmediateInterruptOK set over a
> much larger code range in PGSemaphoreLock --- and in particular doesn't
> bother to reset it before entering ereport() --- is a horrid idea.
> Keep in mind that setting ImmediateInterruptOK means you can lose control
> *anywhere*, and so have no ability to safely manipulate anything except
> local variables.
What's wrong with ereport(FATAL) under ImmediateInterruptOK?
ClientAuthentication() does it, and errfinish() clears the flag.
--
Noah Misch
EnterpriseDB http://www.enterprisedb.com
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugsAttachments:w32-io-completion-v2.patch (text/plain, 3.1K) download
*** a/src/backend/port/win32/socket.c
--- b/src/backend/port/win32/socket.c
***************
*** 623,629 **** pgwin32_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, c
return 0;
}
! if (r == WAIT_OBJECT_0 + numevents)
{
pgwin32_dispatch_queued_signals();
errno = EINTR;
--- 623,630 ----
return 0;
}
! /* Signal-like events. */
! if (r == WAIT_OBJECT_0 + numevents || r == WAIT_IO_COMPLETION)
{
pgwin32_dispatch_queued_signals();
errno = EINTR;
*** a/src/backend/port/win32_sema.c
--- b/src/backend/port/win32_sema.c
***************
*** 118,125 **** PGSemaphoreReset(PGSemaphore sema)
void
PGSemaphoreLock(PGSemaphore sema, bool interruptOK)
{
- DWORD ret;
HANDLE wh[2];
/*
* Note: pgwin32_signal_event should be first to ensure that it will be
--- 118,125 ----
void
PGSemaphoreLock(PGSemaphore sema, bool interruptOK)
{
HANDLE wh[2];
+ bool done = false;
/*
* Note: pgwin32_signal_event should be first to ensure that it will be
***************
*** 135,168 **** PGSemaphoreLock(PGSemaphore sema, bool interruptOK)
* no hidden magic about whether the syscall will internally service a
* signal --- we do that ourselves.
*/
! do
{
ImmediateInterruptOK = interruptOK;
CHECK_FOR_INTERRUPTS();
! ret = WaitForMultipleObjectsEx(2, wh, FALSE, INFINITE, TRUE);
!
! if (ret == WAIT_OBJECT_0)
! {
! /* Signal event is set - we have a signal to deliver */
! pgwin32_dispatch_queued_signals();
! errno = EINTR;
! }
! else if (ret == WAIT_OBJECT_0 + 1)
{
! /* We got it! */
! errno = 0;
}
! else
! /* Otherwise we are in trouble */
! errno = EIDRM;
!
! ImmediateInterruptOK = false;
! } while (errno == EINTR);
!
! if (errno != 0)
! ereport(FATAL,
! (errmsg("could not lock semaphore: error code %lu", GetLastError())));
}
/*
--- 135,178 ----
* no hidden magic about whether the syscall will internally service a
* signal --- we do that ourselves.
*/
! while (!done)
{
+ DWORD rc;+
ImmediateInterruptOK = interruptOK;
CHECK_FOR_INTERRUPTS();
+ rc = WaitForMultipleObjectsEx(2, wh, FALSE, INFINITE, TRUE);+ ImmediateInterruptOK = false;
! switch (rc)
{
! case WAIT_OBJECT_0:
! /* Signal event is set - we have a signal to deliver */
! pgwin32_dispatch_queued_signals();
! break;
! case WAIT_OBJECT_0 + 1:
! /* We got it! */
! done = true;
! break;
! case WAIT_IO_COMPLETION:
! /*
! * The system interrupted the wait to execute an I/O
! * completion routine or asynchronous procedure call in this
! * thread. PostgreSQL does not provoke either of these, but
! * atypical loaded DLLs or even other processes might do so.
! * Now, resume waiting.
! */
! break;
! case WAIT_FAILED:
! ereport(FATAL,
! (errmsg("could not lock semaphore: error code %lu",
! GetLastError())));
! break;
! default:
! elog(FATAL, "unexpected return code from WaitForMultipleObjectsEx(): %lu", rc);
! break;
}
! }
}
/*
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-bugs@postgresql.org
Cc: noah@leadboat.com, tgl@sss.pgh.pa.us, shivshi@cisco.com, alvherre@2ndquadrant.com
Subject: Re: PostgreSQL 6.2.5 Visual Studio Build does not pass the regression tests.
In-Reply-To: <20140124213656.GB2001840@tornado.leadboat.com>
References: <CEB3FA9D.6450%shivshi@cisco.com> <20140124042742.GA1975540@tornado.leadboat.com> <12094.1390576464@sss.pgh.pa.us> <20140124213656.GB2001840@tornado.leadboat.com>
* 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