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

Gábor Stefanik gabor.stefanik at nng.com
Mon Aug 21 11:19:00 EDT 2017


# HG changeset patch
# User Gábor Stefanik <gabor.stefanik at nng.com>
# 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.

diff -r 242d719e85ce -r e2b082707b44 hglib/client.py
--- a/hglib/client.py   Mon Aug 21 16:39:17 2017 +0200
+++ b/hglib/client.py   Mon Aug 21 17:02:14 2017 +0200
@@ -139,6 +139,7 @@
     def _readchannel(self):
         data = self.server.stdout.read(hgclient.outputfmtsize)
         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
________________________________
 This message, including its attachments, is confidential and the property of NNG Llc. For more information please read NNG's email policy here:
http://www.nng.com/emailpolicy/
By responding to this email you accept the email policy.


More information about the Mercurial-devel mailing list