This is an archive of the discontinued Mercurial Phabricator instance.

zeroconf: do not crash if socket being read is closed by another thread
ClosedPublic

Authored by quark on Oct 2 2017, 11:23 PM.

Details

Summary

In zeroconf/__init__.py, there is:

server = Zeroconf.Zeroconf(ip)
l = listener()
Zeroconf.ServiceBrowser(server, "_hg._tcp.local.", l)
time.sleep(1)
server.close()

server.close() closes the underlying socket while the ServiceBrowser may
still have a background thread reading the socket. There could be a race
condition where the reading thread reads the closed socket, resulting in
EBADF crash. This patch catches the exception.

This makes test-paths.t pass with chg.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

quark created this revision.Oct 2 2017, 11:23 PM
This revision was automatically updated to reflect the committed changes.