Skip to content

Commit

Permalink
pybind/ceph_daemon: use small chunk for recv
Browse files Browse the repository at this point in the history
socket.recv(bufsize) accept signed int in python, so if
we want to load huge data (mds -> cache_dump is an instance)
from admin socket , an EOVERFLOW exception will be throw.

Walk around this by only get READ_CHUNK_SIZE(4096) bytes data each call.

Signed-off-by: Xiaoxi Chen <xiaoxchen@ebay.com>
  • Loading branch information
xiaoxichen committed Mar 9, 2017
1 parent f903f2f commit f223309
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/pybind/ceph_daemon.py
Expand Up @@ -21,6 +21,7 @@

COUNTER = 0x8
LONG_RUNNING_AVG = 0x4
READ_CHUNK_SIZE = 4096


def admin_socket(asok_path, cmd, format=''):
Expand All @@ -45,7 +46,10 @@ def do_sockio(path, cmd_bytes):

got = 0
while got < l:
bit = sock.recv(l - got)
# recv() receives signed int, i.e max 2GB
# walk around by request max READ_CHUNK_SIZE per call.
want = min(l - got, READ_CHUNK_SIZE)
bit = sock.recv(want)
sock_ret += bit
got += len(bit)

Expand Down

0 comments on commit f223309

Please sign in to comment.