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:
def shutdown_zeo_server(adminaddr):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(adminaddr)
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()
# Do this in a loop to guard against the possibility that the
# client failed to connect to the adminaddr earlier. That really
# only requires two iterations, but do a third for pure
# superstition.
for i in range(3):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
s.connect(adminaddr)
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