Commit e6e7681a authored by Jeremy Hylton's avatar Jeremy Hylton

Port more-robust shutdown_zeo_server() from Zope-2_7-branch.

parent 490828e6
...@@ -123,12 +123,23 @@ else: ...@@ -123,12 +123,23 @@ else:
def shutdown_zeo_server(adminaddr): def shutdown_zeo_server(adminaddr):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # Do this in a loop to guard against the possibility that the
s.connect(adminaddr) # client failed to connect to the adminaddr earlier. That really
try: # only requires two iterations, but do a third for pure
ack = s.recv(1024) # superstition.
except socket.error, e: for i in range(3):
if e[0] <> errno.ECONNRESET: raise s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
ack = 'no ack received' try:
zLOG.LOG('shutdownServer', zLOG.DEBUG, 'acked: %s' % ack) s.connect(adminaddr)
s.close() except socket.error, e:
if e[0] == errno.ECONNREFUSED and i > 0:
break
raise
try:
ack = s.recv(1024)
except socket.error, e:
if e[0] == errno.ECONNRESET:
raise
ack = 'no ack received'
zLOG.LOG('shutdownServer', zLOG.DEBUG, 'acked: %s' % ack)
s.close()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment