Patchwork [2,of,4] client: kill the server on unrecoverable communication errors (issue5516)

mail settings
Submitter Gábor Stefanik
Date Aug. 21, 2017, 4:06 p.m.
Message ID <e2b082707b44c5d9f630.1503331581@GSTEFANIK.NavnGo.local>
Download mbox | patch
Permalink /patch/23182/
State Accepted
Headers show


Gábor Stefanik - Aug. 21, 2017, 4:06 p.m.
# HG changeset patch
# User Gábor Stefanik <>
# Date 1503327734 -7200
#      Mon Aug 21 17:02:14 2017 +0200
# Node ID e2b082707b44c5d9f630bf0ca722723bad8cefb1
# Parent  242d719e85ce451e61ab262eec443668bb4792ce
client: kill the server on unrecoverable communication errors (issue5516)

Once an unrecoverable communication error occurs between the client and server,
it's no longer safe to send further commands to the same server.
On Windows, attempting to do so is known to cause lockups and memory leaks.

Close the client and kill the server when an such an error occurs. This way,
any further commands will fail gracefully with ValueError until the client
is reopened.

 This message, including its attachments, is confidential and the property of NNG Llc. For more information please read NNG's email policy here:
By responding to this email you accept the email policy.


diff -r 242d719e85ce -r e2b082707b44 hglib/

--- a/hglib/   Mon Aug 21 16:39:17 2017 +0200

+++ b/hglib/   Mon Aug 21 17:02:14 2017 +0200

@@ -139,6 +139,7 @@ 

     def _readchannel(self):
         data =
         if not data:
+            self.close()

             raise error.ServerError()
         channel, length = struct.unpack(hgclient.outputfmt, data)
         if channel in b('IL'):
@@ -190,6 +191,7 @@ 

                 return struct.unpack(hgclient.retfmt, data)[0]
             # a channel that we don't know and can't ignore
             elif channel.isupper():
+                self.close()

                 raise error.ResponseError(
                     "unexpected data on required channel '%s'" % channel)
             # optional channel