From: Xiaoxi Chen Date: Mon, 6 Mar 2017 09:31:00 +0000 (-0700) Subject: pybind/ceph_daemon: use small chunk for recv X-Git-Tag: v12.0.1~36^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4e8a19bccf657b6f7ebb8d2093a64a090e655de5;p=ceph.git 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. Workaround by capping READ_CHUNK_SIZE(4096) bytes each call. Signed-off-by: Xiaoxi Chen --- diff --git a/src/pybind/ceph_daemon.py b/src/pybind/ceph_daemon.py index 505b8656834d..ec81d0cbb4a9 100755 --- a/src/pybind/ceph_daemon.py +++ b/src/pybind/ceph_daemon.py @@ -21,6 +21,7 @@ from ceph_argparse import parse_json_funcsigs, validate_command COUNTER = 0x8 LONG_RUNNING_AVG = 0x4 +READ_CHUNK_SIZE = 4096 def admin_socket(asok_path, cmd, format=''): @@ -45,7 +46,10 @@ def admin_socket(asok_path, cmd, format=''): got = 0 while got < l: - bit = sock.recv(l - got) + # recv() receives signed int, i.e max 2GB + # workaround by capping READ_CHUNK_SIZE per call. + want = min(l - got, READ_CHUNK_SIZE) + bit = sock.recv(want) sock_ret += bit got += len(bit)