From 4264e09c6f403dc3ffe3769e7d4b65fce41f0a3c Mon Sep 17 00:00:00 2001 From: Gaige B Paulsen Date: Wed, 20 Nov 2019 01:09:43 -0500 Subject: [PATCH] fix fromfd on solaris This patches the fromfd code in socketfromfd by grabbing the correct symbol under SmartOS (SunOS). The patch is pretty straightforward, basically switching on the OS to determine what the symbol is likely to be. If need be, I could put a try block around the original libc.getsockopt and then fall back to looking for _so_getsockopt, if that's preferred in this codebase fix #2184 --- gunicorn/socketfromfd.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gunicorn/socketfromfd.py b/gunicorn/socketfromfd.py index 4c2847b2..69299200 100644 --- a/gunicorn/socketfromfd.py +++ b/gunicorn/socketfromfd.py @@ -10,6 +10,8 @@ import ctypes import os import socket import sys +import platform + from ctypes.util import find_library __all__ = ('fromfd',) @@ -34,8 +36,10 @@ def _errcheck_errno(result, func, arguments): raise OSError(errno, os.strerror(errno)) return arguments - -_libc_getsockopt = libc.getsockopt +if platform.system() == 'SunOS': + _libc_getsockopt = libc._so_getsockopt +else: + _libc_getsockopt = libc.getsockopt _libc_getsockopt.argtypes = [ ctypes.c_int, # int sockfd ctypes.c_int, # int level