Code review comment for lp:~spiv/bzr/win-serve-error

Revision history for this message
Robert Collins (lifeless) wrote :

On Wed, 2009-05-27 at 15:25 +0000, Andrew Bennetts wrote:
> - bytes = osutils.until_no_eintr(self.socket.recv,
> _MAX_READ_SIZE)
> + try:
> + bytes = osutils.until_no_eintr(self.socket.recv,
> _MAX_READ_SIZE)
> + except socket.error, e:
> + if e.args[0] in (errno.ECONNRESET, 10054):
> + # The connection was closed by the other side.
> + return ''
> + raise
> self._report_activity(len(bytes), 'read')
> return bytes

How about
- bytes = osutils.until_no_eintr(self.socket.recv, _MAX_READ_SIZE)
+ try:
+ bytes = osutils.until_no_eintr(self.socket.recv, _MAX_READ_SIZE)
+ except socket.error, e:
+ if e.args[0] in (errno.ECONNRESET, 10054):
+ # The connection was closed by the other side.
+ bytes = ''
+ else:
+ raise
         self._report_activity(len(bytes), 'read')
         return bytes

This avoids having a different code path exiting the function and may
scale better as other cases need to be caught.

-Rob

« Back to merge proposal