Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W6oR2-0003iX-Sb for pgsql-bugs@arkaria.postgresql.org; Fri, 24 Jan 2014 21:37:09 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1W6oR2-00082K-80 for pgsql-bugs@arkaria.postgresql.org; Fri, 24 Jan 2014 21:37:08 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W6oR1-00082E-Dw for pgsql-bugs@postgresql.org; Fri, 24 Jan 2014 21:37:07 +0000 Received: from mail-qa0-f48.google.com ([209.85.216.48]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W6oQy-0000zw-Jh for pgsql-bugs@postgresql.org; Fri, 24 Jan 2014 21:37:06 +0000 Received: by mail-qa0-f48.google.com with SMTP id f11so4599957qae.35 for ; Fri, 24 Jan 2014 13:37:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=fTlODaJYH+kED1C9WNRfbm0gd4N38E8D3FuGxTF5f68=; b=aJbZQZktzZTersAHTFFJr5ctwFAKaFd2UsL4iP7EwXnV2bzQ6piXXR0JNLKiRsNR4F eP8wHhx2JtErSxeCg9dEHYi9Ir8QmPfVbK+LiVC5Q+JxQUbJKGyKHGOVfxQgQguGe0xF w9JuhFJBK7gvd0pI5dWqkprAybw83MrlDpZpgBvaDlqEWZaU8HgVoF1VYt53tt0A7uXV DLsjH8GZTOInt8FEAnJigJCd6TdViQCPKBm/8R5BXHgVnhmY8h72emsZAk2jsMvP441t dsuLgoDAX+HoNlEkmcQf39/od7ORNp0TaTooq9DqPPeLGYEedCqyk8m9z4qznUxNt1WR Wqhg== X-Gm-Message-State: ALoCoQlewRfXWrT7LcMAK4m5jgbCnbg837M3tBgu5cjHpGkQs9T1bGwnL5uVZRzNgkN5sC2SeMXS X-Received: by 10.140.31.75 with SMTP id e69mr22953605qge.76.1390599423795; Fri, 24 Jan 2014 13:37:03 -0800 (PST) Received: from tornado.leadboat.com (c-107-4-219-91.hsd1.va.comcast.net. [107.4.219.91]) by mx.google.com with ESMTPSA id m9sm4829599qaz.8.2014.01.24.13.36.57 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 24 Jan 2014 13:36:58 -0800 (PST) Date: Fri, 24 Jan 2014 16:36:56 -0500 From: Noah Misch To: Tom Lane Cc: "Shiv Shivaraju Gowda (shivshi)" , "pgsql-bugs@postgresql.org" , alvherre@2ndquadrant.com Subject: Re: Re: PostgreSQL 6.2.5 Visual Studio Build does not pass the regression tests. Message-ID: <20140124213656.GB2001840@tornado.leadboat.com> References: <20140124042742.GA1975540@tornado.leadboat.com> <12094.1390576464@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="tKW2IUtsqtDRztdT" Content-Disposition: inline In-Reply-To: <12094.1390576464@sss.pgh.pa.us> User-Agent: Mutt/1.5.21 (2010-09-15) X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org --tKW2IUtsqtDRztdT Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Jan 24, 2014 at 10:14:24AM -0500, Tom Lane wrote: > Noah Misch 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 --tKW2IUtsqtDRztdT Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="w32-io-completion-v2.patch" *** 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; } ! } } /* --tKW2IUtsqtDRztdT Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs --tKW2IUtsqtDRztdT--