summaryrefslogtreecommitdiff
path: root/daemons/lvmdbusd/utils.py
diff options
context:
space:
mode:
authorTony Asleson <tasleson@redhat.com>2021-06-11 10:35:31 -0500
committerTony Asleson <tasleson@redhat.com>2021-06-17 09:14:29 -0500
commitc474f174cc8b0e855f984bf211f5416b42c644a1 (patch)
tree7c234bce2c4fdb439940b85b751ae2b138e4709d /daemons/lvmdbusd/utils.py
parent71cb54d92f96b8da318c8f8380e7ce0bdf0a11bf (diff)
downloadlvm2-c474f174cc8b0e855f984bf211f5416b42c644a1.tar.gz
lvmdbusd: Handle arbitrary amounts stdout & stderr
When exec'ing lvm, it's possible to get large amounts of both stdout and stderr depending on the state of lvm and the size of the lvm configuration. If we allow any of the buffers to fill we can end up deadlocking the process. Ensure we are handling stdout & stderr during lvm execution. Ref. https://bugzilla.redhat.com/show_bug.cgi?id=1966636 Signed-off-by: Tony Asleson <tasleson@redhat.com>
Diffstat (limited to 'daemons/lvmdbusd/utils.py')
-rw-r--r--daemons/lvmdbusd/utils.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/daemons/lvmdbusd/utils.py b/daemons/lvmdbusd/utils.py
index 66dfbd691..cc221fc2d 100644
--- a/daemons/lvmdbusd/utils.py
+++ b/daemons/lvmdbusd/utils.py
@@ -14,6 +14,7 @@ import ctypes
import os
import string
import datetime
+from fcntl import fcntl, F_GETFL, F_SETFL
import dbus
from lvmdbusd import cfg
@@ -681,3 +682,16 @@ def _remove_objects(dbus_objects_rm):
# Remove dbus objects from main thread
def mt_remove_dbus_objects(objs):
MThreadRunner(_remove_objects, objs).done()
+
+
+# Make stream non-blocking
+def make_non_block(stream):
+ flags = fcntl(stream, F_GETFL)
+ fcntl(stream, F_SETFL, flags | os.O_NONBLOCK)
+
+
+def read_decoded(stream):
+ tmp = stream.read()
+ if tmp:
+ return tmp.decode("utf-8")
+ return ''