From 0380ff3d85b7564c11413d985e0f3cd3bb673635 Mon Sep 17 00:00:00 2001 From: Bob Clary Date: Fri, 11 Dec 2020 12:15:31 +0000 Subject: [PATCH] Bug 1681311 - Guard against unclean shutdown when closing socket in testing/marionette/client/marionette_driver/transport.py. r=marionette-reviewers,jgraham Differential Revision: https://phabricator.services.mozilla.com/D99438 --- testing/marionette/client/marionette_driver/transport.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/testing/marionette/client/marionette_driver/transport.py b/testing/marionette/client/marionette_driver/transport.py index 97dcdee1c6fd..679b14562fd7 100644 --- a/testing/marionette/client/marionette_driver/transport.py +++ b/testing/marionette/client/marionette_driver/transport.py @@ -305,8 +305,10 @@ class TcpTransport(object): if exc.errno not in (57, 107): raise - self._sock.close() - self._sock = None + if self._sock: + # Guard against unclean shutdown. + self._sock.close() + self._sock = None def __del__(self): self.close()