[MERGE] Re: [Bug 115781] Re: traceback on smart server when branching/pulling (win32)
John Arbash Meinel
john at arbash-meinel.com
Tue Dec 18 19:47:01 GMT 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Andrew Bennetts wrote:
> [moving discussion to list so that people can review the code]
>
> Alexander Belchenko wrote:
>> Andrew Bennetts пишет:
> [...]
>>> connection. My guess is that we're getting a 10055 (WSAENOBUFS) because
>>> we're trying to write several megabytes to the socket in a single call,
>>> which would trip over <http://support.microsoft.com/kb/201213>.
>>>
>>> If that hypothesis is right, then a patch like this should fix the
>>> problem:
>>>
>>> === modified file 'bzrlib/smart/medium.py'
>>> --- bzrlib/smart/medium.py 2007-12-03 16:39:11 +0000
>>> +++ bzrlib/smart/medium.py 2007-12-18 00:04:58 +0000
>>> @@ -177,7 +177,10 @@
>>> self.finished = True
>>>
>>> def _write_out(self, bytes):
>>> - self.socket.sendall(bytes)
>>> + while bytes:
>>> + chunk = bytes[:65536]
>>> + bytes = bytes[65536:]
>>> + self.socket.sendall(chunk)
>>>
>>>
>>> class SmartServerPipeStreamMedium(SmartServerStreamMedium):
>>>
>>> (i.e., never write more than 64k at a time in SmartServerSocketStreamMedium)
>> This patch helps. Do you need more testing from me?
>> If not -- please, merge it to bzr.dev.
>
> Sending to the list for feedback.
>
> It's probably better to write the loop as:
>
> chunk_size = 2**16
> pos = 0
> while pos < len(bytes):
> chunk = bytes[pos:pos+chunk_size]
> pos += chunk_size
> self.socket.sendall(chunk)
>
> This way we avoid copying multi-megabyte strings in memory repeatedly.
>
> Attached is the patch for review. It has the improved loop, a comment, and a
> NEWS entry. See https://bugs.launchpad.net/bzr/+bug/115781 for the complete
> discussion about the problem.
>
> Alexander, thanks for testing the patches!
>
> -Andrew.
>
>
bb:tweak
I prefer Alexander's xrange() version, as it makes getting boundary cases
trivial, instead of worrying about them.
I've also typically done:
chunk_size = 1 << 16
rather than
chunk_size = 2**16
but they are the same value, so I don't really care.
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD4DBQFHaCO0JdeBCYSNAAMRAgLNAJ45XOqvQlJk95/Y4Zhx3dJJbJj9xwCYrrT8
k8J8RrnqUo3NqQxU64ARjA==
=ynjJ
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list