Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YLxx0-00041y-Br for pgsql-bugs@arkaria.postgresql.org; Thu, 12 Feb 2015 17:53:18 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YLxwz-00010E-SF for pgsql-bugs@arkaria.postgresql.org; Thu, 12 Feb 2015 17:53:17 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YLxwz-000108-8f for pgsql-bugs@postgresql.org; Thu, 12 Feb 2015 17:53:17 +0000 Received: from mail.anarazel.de ([217.115.131.40]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YLxwv-0006qi-6Y for pgsql-bugs@postgresql.org; Thu, 12 Feb 2015 17:53:16 +0000 Received: from intern.anarazel.de (static-11-203-78-212.thenetworkfactory.nl [212.78.203.11]) (Authenticated sender: andres@anarazel.de) by mail.anarazel.de (Postfix) with ESMTPSA id DB021460002; Thu, 12 Feb 2015 18:53:11 +0100 (CET) Date: Thu, 12 Feb 2015 18:53:05 +0100 From: Andres Freund To: Alvaro Herrera Cc: Asif Naeem , Michael Paquier , "pgsql-bugs@postgresql.org" Subject: Re: gettimeofday cause crash on Windows Message-ID: <20150212175305.GD9449@alap3.anarazel.de> References: <20150212125412.GA9449@alap3.anarazel.de> <20150212131316.GB9449@alap3.anarazel.de> <20150212151403.GJ3391@alvh.no-ip.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20150212151403.GJ3391@alvh.no-ip.org> X-Pg-Spam-Score: -4.2 (----) 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 On 2015-02-12 12:14:03 -0300, Alvaro Herrera wrote: > Asif Naeem wrote: > > Don’t you feel gettimeofday() implementation is incomplete in current > > state, Is there any other example of function port in PG that could lead to > > crash if its related init_* function is not called earlier ?. As mentioned > > by Michael, it seems not enough documented (release notes etc), at least it > > need to give warning etc instead of simply crash the related process. > > GetSystemTimeAsFileTime() function is less precise but it is quite fast and > > less CPU intensive then GetSystemTimePreciseAsFileTime() function, > > GetSystemTimePreciseAsFileTime() can effect performance of an application. > > With the proposed patch, gettimeofday() function is more safe and more > > versatile, a contrib may use it as per its need of precision. Thanks. > > Ideally we would the Precise dance automatically, without requiring the > program to call an initialization function. Otherwise, programs may > never be updated to use Precise rather than the stock function. I guess > this is the reason Andres prefers a crash: to force programs to be > updated to include the initialization step. > > I wonder if it would work to set the function initially to the > initialization function, so that on the first call the Precise version, > if it exists, is detected (or the stock version otherwise) and set as > the function to call for later -- without requiring a jump in every > subsequent execution of gettimeofday(), of course. The initialization > function itself would have to return the value returned by > GetSystemTimePreciseAsFileTime, of course. Yes, that sounds like a good idea. Greetings, Andres Freund -- Andres Freund http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs