Permalink
Browse files

Handle responses that require more than one recv call - bug 1477

Change-Id: I19d34001724d110811db4e678d80950d9946970f
Reviewed-on: http://review.northscale.com:8080/814
Tested-by: Dustin Sallings <dustin@spy.net>
Reviewed-by: Dustin Sallings <dustin@spy.net>
  • Loading branch information...
1 parent e550e29 commit c8920324ba454cc87409603877852367cfd8fc65 @seanlynch seanlynch committed with dustin Mar 17, 2010
Showing with 7 additions and 4 deletions.
  1. +7 −4 management/mc_bin_client.py
@@ -62,10 +62,13 @@ def _handleKeyedResponse(self, myopaque):
assert len(response) == MIN_RECV_PACKET
magic, cmd, keylen, extralen, dtype, errcode, remaining, opaque, cas=\
struct.unpack(RES_PKT_FMT, response)
- if remaining > 0:
- rv=self.s.recv(remaining)
- else:
- rv=""
+
+ rv = ""
+ while remaining > 0:
+ data = self.s.recv(remaining)
+ rv += data
+ remaining -= len(data)
+
assert (magic in (RES_MAGIC_BYTE, REQ_MAGIC_BYTE)), "Got magic: %d" % magic
assert myopaque is None or opaque == myopaque, \
"expected opaque %x, got %x" % (myopaque, opaque)

0 comments on commit c892032

Please sign in to comment.