overlord: ghost: reset connection when connection is closed

If the control channel is closed cleanly, read() will return an empty
string. Reset connection is such case.

BUG=none
TEST=manually

Change-Id: I94b37ea8fdd6ecc4d9b62e26cc5474c6a9654f24
Reviewed-on: https://chromium-review.googlesource.com/314240
Commit-Ready: Wei-Ning Huang <wnhuang@chromium.org>
Tested-by: Wei-Ning Huang <wnhuang@chromium.org>
Reviewed-by: Wei-Ning Huang <wnhuang@chromium.org>
diff --git a/py/tools/ghost.py b/py/tools/ghost.py
index 652755d..67791ec 100755
--- a/py/tools/ghost.py
+++ b/py/tools/ghost.py
@@ -794,7 +794,14 @@
         rds, _, _ = select.select([self._sock], [], [], _PING_INTERVAL / 2)
 
         if self._sock in rds:
-          self._buf += self._sock.recv(_BUFSIZE)
+          data = self._sock.recv(_BUFSIZE)
+
+          # Socket is closed
+          if len(data) == 0:
+            self.Reset()
+            break
+
+          self._buf += data
           self.ParseMessage(self._register_status != SUCCESS)
 
         if (self._mode == self.AGENT and