From f22330909382fde4e28794ff26130e34bfe8cb04 Mon Sep 17 00:00:00 2001 From: Xiaoxi Chen Date: Mon, 6 Mar 2017 02:31:00 -0700 Subject: [PATCH] pybind/ceph_daemon: use small chunk for recv 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 --- src/pybind/ceph_daemon.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pybind/ceph_daemon.py b/src/pybind/ceph_daemon.py index 505b8656834db5..ae678661046a1b 100755 --- a/src/pybind/ceph_daemon.py +++ b/src/pybind/ceph_daemon.py @@ -21,6 +21,7 @@ COUNTER = 0x8 LONG_RUNNING_AVG = 0x4 +READ_CHUNK_SIZE = 4096 def admin_socket(asok_path, cmd, format=''): @@ -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)