Re: Restart pg_usleep when interrupted - Mailing list pgsql-hackers

From Nathan Bossart
Subject Re: Restart pg_usleep when interrupted
Date
Msg-id Zo_7blmO166ZDGbW@nathan
Whole thread Raw
In response to Re: Restart pg_usleep when interrupted  (Sami Imseih <samimseih@gmail.com>)
Responses Re: Restart pg_usleep when interrupted
List pgsql-hackers
+        /*
+         * We allow nanosleep to handle interrupts and retry with the remaining time.
+         * However, since nanosleep is susceptible to time drift when interrupted
+         * frequently, we add a safeguard to break out of the nanosleep whenever the
+         * total time of the sleep exceeds the requested sleep time. Using nanosleep
+         * is a more portable approach than clock_nanosleep.
+         */

I'm curious why we wouldn't just subtract "elapsed_time" from "delay" at
the bottom of the while loop to avoid needing this extra check.  Also, I
think we need some commentary about why we want to retry after an interrupt
in this case.

-- 
nathan



pgsql-hackers by date:

Previous
From: Sami Imseih
Date:
Subject: Re: Restart pg_usleep when interrupted
Next
From: Dave Page
Date:
Subject: Re: tests fail on windows with default git settings