Comment 6 for bug 1849971

Revision history for this message
Olaf Seibert (rhialto) wrote :

There may be some race condition involved. I added a check for sock._closed, and still the EINVAL came in one case.

Code as tested:

    def shutdown_socket(self, sock):
        """Properly shutdown a socket.

        This should be called only when no other thread is trying to use the
        socket.
        """
        if not sock._closed:
            try:
                # import pdb; pdb.set_trace()
                sock.shutdown(socket.SHUT_RDWR) # fails with EINVAL
                sock.close()
            except Exception as e:
                import pdb; pdb.set_trace()
                if self.ignored_exceptions(e):
                    pass
                else:
                    raise

...x.test_commit.TestCommit.test_verbose_commit_with_unchanged OK 128ms
...box.test_commit.TestCommit.test_verbose_commit_with_unknown OK 281ms
..._commit.TestCommit.test_warn_about_forgotten_commit_message OK 78ms
...est_commit.TestSmartServerCommit.test_commit_to_lightweight> /home/tmp/devel/breezy/work.x86_64/breezy-3.0.1/breezy/tests/test_server.py(390)shutdown_socket()
-> if self.ignored_exceptions(e):
(Pdb) e
OSError(22, 'Invalid argument')
(Pdb) sock
<socket.socket [closed] fd=-1, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0>
(Pdb) sock._closed
True

-Olaf.