Dima Kuznetsov has uploaded a new change for review.

Change subject: infra: Switch utils calls to filecontrol
......................................................................

infra: Switch utils calls to filecontrol

Change all call to functions moved to filecontrol to appropriate module
and remove old calls from utils

Change-Id: I2ddeaaf304679d475252fcda6c498fc991704792
Signed-off-by: Dima Kuznetsov <[email protected]>
---
M lib/vdsm/utils.py
M vdsm/protocoldetector.py
M vdsm/storage/remoteFileHandler.py
3 files changed, 9 insertions(+), 20 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/19/35919/1

diff --git a/lib/vdsm/utils.py b/lib/vdsm/utils.py
index db38e0c..3fecb65 100644
--- a/lib/vdsm/utils.py
+++ b/lib/vdsm/utils.py
@@ -33,7 +33,6 @@
 from weakref import proxy
 from .compat import pickle
 import errno
-import fcntl
 import functools
 import glob
 import io
@@ -839,11 +838,6 @@
     return splits + [l]
 
 
-def closeOnExec(fd):
-    old = fcntl.fcntl(fd, fcntl.F_GETFD, 0)
-    fcntl.fcntl(fd, fcntl.F_SETFD, old | fcntl.FD_CLOEXEC)
-
-
 class memoized(object):
     """
     Decorator that caches a function's return value each time it is called.
@@ -1144,12 +1138,6 @@
         yield runnable
     finally:
         runnable.stop()
-
-
-def set_non_blocking(fd):
-    flags = fcntl.fcntl(fd, fcntl.F_GETFL)
-    flags |= os.O_NONBLOCK
-    fcntl.fcntl(fd, fcntl.F_SETFL, flags)
 
 
 def get_selinux_enforce_mode():
diff --git a/vdsm/protocoldetector.py b/vdsm/protocoldetector.py
index 403c784..0b8ff60 100644
--- a/vdsm/protocoldetector.py
+++ b/vdsm/protocoldetector.py
@@ -28,7 +28,7 @@
 from M2Crypto import SSL
 
 from vdsm.utils import traceback
-from vdsm import utils
+import vdsm.infra.filecontrol as filecontrol
 
 
 def _is_handshaking(sock):
@@ -74,10 +74,10 @@
         self._port = port
 
         self._read_fd, self._write_fd = os.pipe()
-        utils.set_non_blocking(self._read_fd)
-        utils.closeOnExec(self._read_fd)
-        utils.set_non_blocking(self._write_fd)
-        utils.closeOnExec(self._write_fd)
+        filecontrol.set_non_blocking(self._read_fd)
+        filecontrol.set_close_on_exec(self._read_fd)
+        filecontrol.set_non_blocking(self._write_fd)
+        filecontrol.set_close_on_exec(self._write_fd)
 
         self._socket = self._create_socket(host, port)
         self._poller = select.poll()
@@ -269,7 +269,7 @@
             raise Exception("Could not translate address '%s:%s'"
                             % (self._host, str(self._port)))
         server_socket = socket.socket(addr[0][0], addr[0][1], addr[0][2])
-        utils.closeOnExec(server_socket.fileno())
+        filecontrol.set_close_on_exec(server_socket.fileno())
         server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
         server_socket.bind(addr[0][4])
         server_socket.listen(5)
diff --git a/vdsm/storage/remoteFileHandler.py 
b/vdsm/storage/remoteFileHandler.py
index ec0511c..89e3989 100644
--- a/vdsm/storage/remoteFileHandler.py
+++ b/vdsm/storage/remoteFileHandler.py
@@ -46,6 +46,7 @@
 import misc
 import fileUtils
 import vdsm.infra.zombiereaper as zombiereaper
+import vdsm.infra.filecontrol as filecontrol
 from vdsm.compat import pickle
 from vdsm import utils
 
@@ -126,8 +127,8 @@
     def __init__(self, myRead, myWrite):
         self._myWrite = myWrite
         self._myRead = myRead
-        utils.set_non_blocking(self._myWrite)
-        utils.set_non_blocking(self._myRead)
+        filecontrol.set_non_blocking(self._myWrite)
+        filecontrol.set_non_blocking(self._myRead)
         self._poller = select.poll()
 
     @contextmanager


-- 
To view, visit http://gerrit.ovirt.org/35919
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2ddeaaf304679d475252fcda6c498fc991704792
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dima Kuznetsov <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to