~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/protocol.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-01-22 00:46:23 UTC
  • mfrom: (3170.5.2 windows-recv-limit)
  • Revision ID: pqm@pqm.ubuntu.com-20080122004623-p8kb5y8dehs5cmho
(andrew) Don't read more than 64k at a time in bzrlib/smart/medium.py,
        fixes the other half of bug #115781.

Show diffs side-by-side

added added

removed removed

Lines of Context:
549
549
            return self._body_buffer.read(count)
550
550
        _body_decoder = LengthPrefixedBodyDecoder()
551
551
 
 
552
        # Read no more than 64k at a time so that we don't risk error 10055 (no
 
553
        # buffer space available) on Windows.
 
554
        max_read = 64 * 1024
552
555
        while not _body_decoder.finished_reading:
553
 
            bytes_wanted = _body_decoder.next_read_size()
 
556
            bytes_wanted = min(_body_decoder.next_read_size(), max_read)
554
557
            bytes = self._request.read_bytes(bytes_wanted)
555
558
            _body_decoder.accept_bytes(bytes)
556
559
        self._request.finished_reading()
633
636
    def read_streamed_body(self):
634
637
        """Read bytes from the body, decoding into a byte stream.
635
638
        """
 
639
        # Read no more than 64k at a time so that we don't risk error 10055 (no
 
640
        # buffer space available) on Windows.
 
641
        max_read = 64 * 1024
636
642
        _body_decoder = ChunkedBodyDecoder()
637
643
        while not _body_decoder.finished_reading:
638
 
            bytes_wanted = _body_decoder.next_read_size()
 
644
            bytes_wanted = min(_body_decoder.next_read_size(), max_read)
639
645
            bytes = self._request.read_bytes(bytes_wanted)
640
646
            _body_decoder.accept_bytes(bytes)
641
647
            for body_bytes in iter(_body_decoder.read_next_chunk, None):