Re: Restart pg_usleep when interrupted

From: Nathan Bossart <nathandbossart(at)gmail(dot)com>
To: Sami Imseih <samimseih(at)gmail(dot)com>
Cc: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Restart pg_usleep when interrupted
Date: 2024-07-11 15:34:06
Message-ID: Zo_7blmO166ZDGbW@nathan
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dave Page 2024-07-11 15:49:00 Re: tests fail on windows with default git settings
Previous Message Sami Imseih 2024-07-11 15:19:22 Re: Restart pg_usleep when interrupted