Patchwork [2,of,2,STABLE] commandserver: get around ETIMEDOUT raised by selectors2

login
register
mail settings
Submitter Yuya Nishihara
Date Dec. 3, 2018, 1:04 p.m.
Message ID <35a596a6b8fa1cb71271.1543842284@mimosa>
Download mbox | patch
Permalink /patch/36921/
State Accepted
Headers show

Comments

Yuya Nishihara - Dec. 3, 2018, 1:04 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1543841115 -32400
#      Mon Dec 03 21:45:15 2018 +0900
# Branch stable
# Node ID 35a596a6b8fa1cb71271d6d4681b0ff7883ea25c
# Parent  d1bda397df7330fb192a94dcb0801928a2492074
commandserver: get around ETIMEDOUT raised by selectors2

selector.select() should exits with an empty event list on timed out, but
selectors2 raises OSError if timeout expires while recovering from EINTR.

Spotted while debugging new chg feature.
Augie Fackler - Dec. 3, 2018, 7:04 p.m.
On Mon, Dec 03, 2018 at 10:04:44PM +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1543841115 -32400
> #      Mon Dec 03 21:45:15 2018 +0900
> # Branch stable
> # Node ID 35a596a6b8fa1cb71271d6d4681b0ff7883ea25c
> # Parent  d1bda397df7330fb192a94dcb0801928a2492074
> commandserver: get around ETIMEDOUT raised by selectors2

queued for stable, thanks

Patch

diff --git a/mercurial/commandserver.py b/mercurial/commandserver.py
--- a/mercurial/commandserver.py
+++ b/mercurial/commandserver.py
@@ -472,7 +472,15 @@  class unixforkingservice(object):
                 # waiting for recv() will receive ECONNRESET.
                 self._unlinksocket()
                 exiting = True
-            ready = selector.select(timeout=h.pollinterval)
+            try:
+                ready = selector.select(timeout=h.pollinterval)
+            except OSError as inst:
+                # selectors2 raises ETIMEDOUT if timeout exceeded while
+                # handling signal interrupt. That's probably wrong, but
+                # we can easily get around it.
+                if inst.errno != errno.ETIMEDOUT:
+                    raise
+                ready = []
             if not ready:
                 # only exit if we completed all queued requests
                 if exiting: