Revision b18dd019 lib/http/__init__.py

b/lib/http/__init__.py
36 36
from ganeti import utils
37 37

  
38 38

  
39
HTTP_CLIENT_THREADS = 10
40

  
41 39
HTTP_GANETI_VERSION = "Ganeti %s" % constants.RELEASE_VERSION
42 40

  
43 41
HTTP_OK = 200
......
71 69
 SOCKOP_RECV,
72 70
 SOCKOP_SHUTDOWN) = range(3)
73 71

  
72
# send/receive quantum
73
SOCK_BUF_SIZE = 32768
74 74

  
75 75
class HttpError(Exception):
76 76
  """Internal exception for HTTP errors.
......
469 469
    buf = self._FormatMessage()
470 470

  
471 471
    poller = select.poll()
472
    while buf:
473
      # Send only 4 KB at a time
474
      data = buf[:4096]
472

  
473
    pos = 0
474
    end = len(buf)
475
    while pos < end:
476
      # Send only SOCK_BUF_SIZE bytes at a time
477
      data = buf[pos:pos+SOCK_BUF_SIZE]
475 478

  
476 479
      sent = SocketOperation(poller, sock, SOCKOP_SEND, data,
477 480
                             write_timeout)
478 481

  
479 482
      # Remove sent bytes
480
      buf = buf[sent:]
483
      pos += sent
481 484

  
482
    assert not buf, "Message wasn't sent completely"
485
    assert pos == end, "Message wasn't sent completely"
483 486

  
484 487
  def _PrepareMessage(self):
485 488
    """Prepares the HTTP message by setting mandatory headers.
......
555 558
    buf = ""
556 559
    eof = False
557 560
    while self.parser_status != self.PS_COMPLETE:
558
      data = SocketOperation(self.poller, sock, SOCKOP_RECV, 4096,
561
      data = SocketOperation(self.poller, sock, SOCKOP_RECV, SOCK_BUF_SIZE,
559 562
                             read_timeout)
560 563

  
561 564
      if data:

Also available in: Unified diff