From: Michael Hanselmann Date: Fri, 21 Oct 2011 11:22:00 +0000 (+0200) Subject: Un-revert comments in utils.mlock X-Git-Tag: v2.6.0beta1~780 X-Git-Url: https://code.grnet.gr/git/ganeti-local/commitdiff_plain/5fe4a65b7d021441146808dc2e60eea031fcffe5 Un-revert comments in utils.mlock These updates and clarifications are still useful. Signed-off-by: Michael Hanselmann Reviewed-by: René Nussbaumer --- diff --git a/lib/utils/mlock.py b/lib/utils/mlock.py index ea14d68..fc010cd 100644 --- a/lib/utils/mlock.py +++ b/lib/utils/mlock.py @@ -34,7 +34,7 @@ except ImportError: ctypes = None -# Flags for mlockall() (from bits/mman.h) +# Flags for mlockall(2) (from bits/mman.h) _MCL_CURRENT = 1 _MCL_FUTURE = 2 @@ -42,10 +42,10 @@ _MCL_FUTURE = 2 def Mlockall(_ctypes=ctypes): """Lock current process' virtual address space into RAM. - This is equivalent to the C call mlockall(MCL_CURRENT|MCL_FUTURE), - see mlock(2) for more details. This function requires ctypes module. + This is equivalent to the C call C{mlockall(MCL_CURRENT | MCL_FUTURE)}. See + mlockall(2) for more details. This function requires the C{ctypes} module. - @raises errors.NoCtypesError: if ctypes module is not found + @raises errors.NoCtypesError: If the C{ctypes} module is not found """ if _ctypes is None: @@ -60,11 +60,11 @@ def Mlockall(_ctypes=ctypes): logging.error("Cannot set memory lock, ctypes cannot load libc") return - # Some older version of the ctypes module don't have built-in functionality - # to access the errno global variable, where function error codes are stored. - # By declaring this variable as a pointer to an integer we can then access - # its value correctly, should the mlockall call fail, in order to see what - # the actual error code was. + # The ctypes module before Python 2.6 does not have built-in functionality to + # access the global errno global (which, depending on the libc and build + # options, is per thread), where function error codes are stored. Use GNU + # libc's way to retrieve errno(3) instead, which is to use the pointer named + # "__errno_location" (see errno.h and bits/errno.h). # pylint: disable=W0212 libc.__errno_location.restype = _ctypes.POINTER(_ctypes.c_int)