]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/ceph_argparse.py: use a safe value for timeout
authorKefu Chai <kchai@redhat.com>
Sun, 20 Dec 2020 05:10:16 +0000 (13:10 +0800)
committerKefu Chai <kchai@redhat.com>
Sun, 20 Dec 2020 17:26:46 +0000 (01:26 +0800)
we have reports that on arm32 machines, it timed out immediately, so
to prevent it from int overflow, use a safer value instead of
(1 << (32 - 1)) - 1.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/pybind/ceph_argparse.py

index 6e3a7b8e6dcdc3e2447e1e9498fc9e5f4f3ffb88..53faf3cbce54cd87d5a9f1237be3f3be7f245adb 100644 (file)
@@ -1312,9 +1312,11 @@ def run_in_thread(func, *args, **kwargs):
     if timeout == 0 or timeout == None:
         # python threading module will just get blocked if timeout is `None`,
         # otherwise it will keep polling until timeout or thread stops.
-        # wait for INT32_MAX, as python 3.6.8 use int32_t to present the
-        # timeout in integer when converting it to nanoseconds
-        timeout = (1 << (32 - 1)) - 1
+        # timeout in integer when converting it to nanoseconds, but since
+        # python3 uses `int64_t` for the deadline before timeout expires,
+        # we have to use a safe value which does not overflow after being
+        # added to current time in microseconds.
+        timeout = 24 * 60 * 60
     t = RadosThread(func, *args, **kwargs)
 
     # allow the main thread to exit (presumably, avoid a join() on this