fix IBM i 'missing libc' failure (#2195)

allow gunicorn on IBM i (and AIX) platform with Python 3.6 and earlier
This commit is contained in:
ThePrez 2019-11-22 15:14:35 -06:00 committed by Benoit Chesneau
parent 291483dd39
commit 4d3ec28046
2 changed files with 13 additions and 4 deletions

View File

@ -20,10 +20,18 @@ SO_DOMAIN = getattr(socket, 'SO_DOMAIN', 39)
SO_TYPE = getattr(socket, 'SO_TYPE', 3)
SO_PROTOCOL = getattr(socket, 'SO_PROTOCOL', 38)
_libc_name = find_library('c')
if _libc_name is not None:
libc = ctypes.CDLL(_libc_name, use_errno=True)
if sys.platform.startswith("aix"):
member = (
'(shr_64.o)' if ctypes.sizeof(ctypes.c_voidp) == 8 else '(shr.o)')
# 0x00040000 correspondes to RTLD_MEMBER, undefined in Python <= 3.6
dlopen_mode = (ctypes.DEFAULT_MODE | 0x00040000 | os.RTLD_NOW)
libc = ctypes.CDLL(_libc_name+member,
use_errno=True,
mode=dlopen_mode)
else:
libc = ctypes.CDLL(_libc_name, use_errno=True)
else:
raise OSError('libc not found')
@ -36,6 +44,7 @@ def _errcheck_errno(result, func, arguments):
raise OSError(errno, os.strerror(errno))
return arguments
if platform.system() == 'SunOS':
_libc_getsockopt = libc._so_getsockopt
else:

View File

@ -659,9 +659,9 @@ def _findWalk_ldpath(name):
if _is_elf(f):
return os.path.basename(f)
prefix = os.path.join(d, 'lib'+name)
for suffix in ['so', 'so.*', '*.so.*']:
for suffix in ['so', 'so.*', '*.so.*', 'a']:
for f in glob('{0}.{1}'.format(prefix, suffix)):
if _is_elf(f):
if _is_elf(f) or suffix == 'a':
return os.path.basename(f)